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 slick | |
/** | |
* This is some code extracted from TimeOut codebase, demonstrating: | |
* - Use of tag typed to avoid mixing session of different DB | |
* - The use of the Reader Monad to compose Actions together and defer the choice of async/sync computation | |
* | |
* I remove the part where we can say if our operation are read only or not (to use different connection), in order to | |
* make things easier. | |
**/ |
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 scala.slick.lifted.CanBeQueryCondition | |
// optionally filter on a column with a supplied predicate | |
case class MaybeFilter[X, Y](val query: scala.slick.lifted.Query[X, Y]) { | |
def filter[T,R:CanBeQueryCondition](data: Option[T])(f: T => X => R) = { | |
data.map(v => MaybeFilter(query.filter(f(v)))).getOrElse(this) | |
} | |
} | |
// example use case | |
import java.sql.Date |
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
#!/usr/bin/env ruby | |
body = STDIN.read | |
body.gsub!(/\{\{\{([^\n]+?)\}\}\}/, '`\1`') | |
body.gsub!(/\{\{\{(.+?)\}\}\}/m){|m| m.each_line.map{|x| "\t#{x}".gsub(/[\{\}]{3}/,'')}.join} | |
body.gsub!(/\=\=\=\=\s(.+?)\s\=\=\=\=/, '### \1') | |
body.gsub!(/\=\=\=\s(.+?)\s\=\=\=/, '## \1') | |
body.gsub!(/\=\=\s(.+?)\s\=\=/, '# \1') | |
body.gsub!(/\=\s(.+?)\s\=[\s\n]*/, '') |
NewerOlder