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._ | |
// 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
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
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
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
// 2.4 is currently the latest but will only work with Scala 2.9 | |
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 sbt._ | |
val output : String = Process("command to run").!! | |
val returnCode: Int = Process("command to run").! |
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 'openssl' | |
require 'base64' | |
require 'json' | |
# Facebook's base64 algorithm is a special "URL" version of the algorithm. | |
def base64_url_decode(str) | |
str += '=' * (4 - str.length.modulo(4)) | |
Base64.decode64(str.tr('-_','+/')) | |
end |
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
# load access token and expiration from database | |
client = Mogli::Client.new(access_token, expiration) | |
user = Mogli::User.find(facebook_id, client) | |
post = {:name => "main title for the post", | |
:caption => "Sub title for the post", | |
:description => "Long description for the post", | |
:picture => "url to a picture for the post", | |
:link => "url to go to when the user clicks on the title", | |
:from => {:name => "Your app's name", | |
:category => "Your app's category", |
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 Facebooker | |
def self.api_key | |
unless @_api_key | |
config = (YAML.load(ERB.new(File.read(File.join(::Rails.root,"config","facebooker.yml"))).result)[::Rails.env]) | |
@_api_key = config["api_key"] | |
end | |
@_api_key | |
end |