Skip to content

Instantly share code, notes, and snippets.

@stphung
stphung / 2LeggedOAuth.scala
Created February 25, 2012 13:52
A function that demonstrates how to do 2-legged OAuth requests with Play 2.0
def doRequest(key: String, secret: String) {
val ck = ConsumerKey(key, secret)
val oauth = OAuth(ServiceInfo(null, null, null, ck))
val calc = OAuthCalculator(ck, RequestToken("", ""))
calc.setSendEmptyTokens(true)
WS.url(endpoint).sign(calc).get.map(response => {
println(response.json)
})
}
@JosephPecoraro
JosephPecoraro / shell-execution.rb
Last active September 10, 2023 10:12
Shell Execution in Ruby
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Synchronous (blocking)
# Returns the output of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111