I started to read novels on Twitter(total length within 140 chars) recently.
Each Bible verse has a story better than those novels. So I am starting to publish Bible verses on Twitter. This is my twitter with Bible verses
If you are familiar with the Bible verse, this may serve as a good reminder and a starting point of inspiration so that you can reflect on the verse.
If you are not familiar with the particular Bible verse, this may serve as a challenge for you to figure out the context of the verse by going back to the Bible and read around the verse and get familiar with it. GSword is a comprehensive Bible study tool you can use for this purpose.
Any way, this is yet another way to read Bible. I hope you find it fun and challenging.
Saturday, August 15, 2009
Twitter through Grails Application
Doing twitter is very easy in grails application.
Here is a barebone twitter service code. Simply put it into your grails-app/services directory
import twitter4j.Twitter
class TwitterService {
boolean transactional = false
def update(String message) {
Twitter twitter = new Twitter("username", "password");
twitter.updateStatus(message);
}
}
Notice the twitter4j package is used here
In your controller or job, define the service
def twitterService
whereever you want to update your twitter, call the service as following:
twitterService.update("I am fine so far")
Here is a barebone twitter service code. Simply put it into your grails-app/services directory
import twitter4j.Twitter
class TwitterService {
boolean transactional = false
def update(String message) {
Twitter twitter = new Twitter("username", "password");
twitter.updateStatus(message);
}
}
Notice the twitter4j package is used here
In your controller or job, define the service
def twitterService
whereever you want to update your twitter, call the service as following:
twitterService.update("I am fine so far")
Friday, August 7, 2009
Google Spell Checker
Inspired by the php blog on google spell checker, Here is my Groovy version:
def spellchecker(String word){
def path = "/tbproxy/spell?lang=en&hl=en";
def urlString = "https://www.google.com"+path
def url = new URL(urlString)
def connection = url.openConnection()
connection.setRequestMethod("POST")
connection.doOutput = true
def post ='<spellrequest textalreadyclipped="0" ignoredups="1" ignoredigits="1" ignoreallcaps="0"><text>'+word+'</text></spellrequest>'
def writer = new OutputStreamWriter(connection.outputStream)
writer.write(post)
writer.flush()
writer.close()
connection.connect()
println "The query:"+word
println "The response:\n"+connection.content.text
}
def x="""
The suggestions are tab-delineated. The .o. attribute is an offset from the start of your query to the misspelled word. .l. is the length of the misspelled w
ord. .s. is the confidence of Google.s suggestion (presumably higher is better, but I.ve only gotten 0 or 1).
"""
println x
spellchecker("love is patient")
spellchecker("weee nottt sxdsasd")
spellchecker("xxx")
spellchecker("toatlygrbg")
The following is the printout:
The query:love is patient
The response:
The query:weee nottt sxdsasd
The response:
weer wee were whee weed not knotty Natty Netty natty sadsasd
The query:xxx
The response:
The query:toatlygrbg
The response:
totally grbg
def spellchecker(String word){
def path = "/tbproxy/spell?lang=en&hl=en";
def urlString = "https://www.google.com"+path
def url = new URL(urlString)
def connection = url.openConnection()
connection.setRequestMethod("POST")
connection.doOutput = true
def post ='<spellrequest textalreadyclipped="0" ignoredups="1" ignoredigits="1" ignoreallcaps="0"><text>'+word+'</text></spellrequest>'
def writer = new OutputStreamWriter(connection.outputStream)
writer.write(post)
writer.flush()
writer.close()
connection.connect()
println "The query:"+word
println "The response:\n"+connection.content.text
}
def x="""
The suggestions are tab-delineated. The .o. attribute is an offset from the start of your query to the misspelled word. .l. is the length of the misspelled w
ord. .s. is the confidence of Google.s suggestion (presumably higher is better, but I.ve only gotten 0 or 1).
"""
println x
spellchecker("love is patient")
spellchecker("weee nottt sxdsasd")
spellchecker("xxx")
spellchecker("toatlygrbg")
The following is the printout:
The query:love is patient
The response:
The query:weee nottt sxdsasd
The response:
The query:xxx
The response:
The query:toatlygrbg
The response:
Subscribe to:
Posts (Atom)