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 net.liftweb.json._ | |
val jsonStr: String = """{"key1":"value1","key2":1}""" | |
val jsonJVal: JValue = parse(jsonStr) | |
val jsonMap: Map[String,Any] = jsonJVal.values.asInstanceOf[Map[String,Any]] | |
for ((key,value) <- jsonMap) { | |
println("key = " + key + ", value = " + value.toString) | |
} | |
println("Key 1's value is " + jsonMap("key1")) |
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
val h = new Http | |
val req = url("url to request").as_!("user name", "password") | |
val rsp = h(req as_str) |
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 DynamicTestClass() { | |
def output() { | |
println("Hello from a dynamically sent class") | |
} | |
} | |
def testFunc[T : Manifest]() : T = { | |
manifest[T].erasure.newInstance().asInstanceOf[T] | |
} | |
val dynamicTestClassInstance = testFunc[DynamicTestClass]() |
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 dispatch._ | |
import net.liftweb.json._ | |
// Nothing to this class | |
class GithubClass | |
/** | |
* A github user | |
*/ | |
case class User(login: String, // login name of hte user |
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
val dispatch = "net.databinder" %% "dispatch-http" % "0.8.6" | |
val liftJson = "net.liftweb" %% "lift-json" % "2.3" |
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 dispatch._ | |
import net.liftweb.json._ | |
val h = new Http | |
val req = url("https://api.github.com/users/brentsowers1/repos") | |
// Gets both the headers and response body | |
val rspStr = h(req >:+ { (headers, req) => | |
val hdrs = headers | |
req as_str |
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
/** | |
* A github user | |
*/ | |
case class User(login: String, // login name of hte user | |
id: Int, // numeric github ID | |
avatar_url: String, // URL to their avatar pic | |
url: String) // API url to retrieve JSON of the user | |
/** | |
* A single code repo. |
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
// Don't or modify remove this, it's needed by the Lift JSON library | |
implicit val formats = net.liftweb.json.DefaultFormats | |
val rspJson = parse(rspStr) | |
// Github response is an array of objects, this will get that array | |
// as a List | |
val rspList = rspJVal.children | |
val rspRepos = for (repoJObj <- rspList) yield repoJObj.extract[Repo] |
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
# Be sure to restart your server when you modify this file. | |
# Your secret key for verifying cookie session data integrity. | |
# If you change this key, all old sessions will become invalid! | |
# Make sure the secret is at least 30 characters and all random, | |
# no regular words or you'll be exposed to dictionary attacks. | |
ActionController::Base.session = { | |
:key => '_<%= app_name %>_session', | |
:secret => '<%= app_secret %>' | |
} |
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
module ApplicationHelper | |
def inner_helper | |
str = content_tag(:p, "inside p content tag") | |
str << "a space should be between the following words: hello" | |
str << " " | |
str << "world" | |
str << "more <span style=\"font-weight:bold;\">dirty HTML</span>" | |
str << content_tag(:div, "inside div content tag") | |
end |