20090827
20090826
20090822
20090528
Hi I am chromium bot. I would tweet when new chromium build available. (powered by AppJet)
This file contains 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
/* appjet:version 0.1 */ | |
import("storage", "cron", "dlog"); | |
// latest build no store | |
if (!storage.latest) { | |
storage.latest = 0; | |
} | |
const BASE_URL = "http://build.chromium.org/buildbot/snapshots/sub-rel-mac/"; | |
var latestBuildNo = wget(BASE_URL + "LATEST"); | |
var latestURL = BASE_URL + latestBuildNo; | |
function get_main() { | |
dlog.info("Call form http"); | |
print(H1("Chromium official build watcher")); | |
print(DIV({style: "font-size: 400%"}, | |
"Latest build is ... ", | |
A({href: latestURL}, latestBuildNo) | |
)); | |
} | |
function get_admin() { | |
if (!appjet.isPreview) { | |
response.redirect("/"); | |
return; | |
} | |
print("welcom admin!"); | |
} | |
function cron_tweet() { | |
dlog.info("Call from Cron"); | |
dlog.info("Latest(storage):" + storage.latest); | |
dlog.info("Latest(site) :" + latestBuildNo); | |
if (storage.latest < latestBuildNo) { | |
storage.latest = latestBuildNo; | |
var res = wpost( | |
"http://twitter.com/statuses/update.json", { | |
status: "Chromium latest build " + latestBuildNo + | |
" available now." + latestURL | |
}, { | |
headers: {Authorization: "Basic " + storage.auth}, | |
complete: true | |
} | |
); | |
} | |
} | |
//storage.cron = scheduleRepeating(new Date("May 19, 2009"), 15, "/tweet", {}, true); | |
//unschedule(storage.cron); | |
//unscheduleAll(); | |
//print(listAll()); | |
//print(new Date); | |
//print((new Date) + 1000); | |
dispatch(); |
20090507
I just made ruby script that notify twitter timeline with Growl for Windows
I also released Ruby/GNTP library.
It's very simple twitter client.
Check twitter time-line every 30 seconds and notify with Grwol.
Code:twitter_notifier.rb
This file contains 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/ruby | |
# | |
# Ruby/GNTP example : twitter notifier | |
# | |
# Usage: {{{ | |
# Please type the following command from command line, | |
# and then, this script gets your time-line every 30 seconds. | |
# | |
# > ruby twitter_notifyer.rb | |
# | |
# If you want *STOP* this script, so press Ctrl + 'C'. | |
# | |
# Require environment variables: | |
# - EDITOR : For Pit uses this variable to edit account information. | |
# ex) set EDITOR = c:\Progra~1\vim71\vim.exe | |
# | |
# - HTTP_PROXY : If you access the Internet via proxy server, you need | |
# this variable setting. | |
# If variable's value icludes protcol scheme('http://' etc.) | |
# would ignore that. | |
# ex) set HTTP_PROXY = http://proxy.host.name:8080 | |
# or | |
# set HTTP_PROXY = proxy.host.name:8080 | |
# | |
# Web page: | |
# http://d.hatena.ne.jp/snaka72/ | |
# http://sumimasen2.blogspot.com/ | |
# | |
# License: public domain | |
# }}} | |
require 'net/http' | |
require 'rubygems' | |
require 'json' | |
require 'pit' | |
require 'gntp' | |
$tweeted = {} | |
$growl = GNTP.new | |
$growl.register({ | |
:app_name => "Twitter", | |
:notifies => [{ :name => "Tweet", :enabled => true }, | |
{ :name => "Error", :enabled => true }] | |
}) | |
def get_timeline | |
max_count = 20 | |
config = Pit.get("twitter", :require => { | |
"username" => "your twittername", | |
"password" => "your password" | |
}) | |
Net::HTTP.version_1_2 | |
req = Net::HTTP::Get.new('/statuses/friends_timeline.json') | |
req.basic_auth config["username"], config["password"] | |
proxy_host, proxy_port = (ENV["HTTP_PROXY"] || '').sub(/http:\/\//, '').split(':') | |
Net::HTTP::Proxy(proxy_host, proxy_port).start('twitter.com') {|http| | |
res = http.request(req) | |
if res.code != '200' | |
$growl.notify({ | |
:name => "Error", | |
:title => "Error occurd", | |
:test => "Can not get messages" | |
}) | |
return | |
end | |
results = JSON.parser.new(res.body).parse() | |
results.reverse! | |
results.length.times do |i| | |
break if i >= max_count | |
id = results[i]["id"] | |
next if $tweeted.include?(id) | |
puts screen_name = results[i]["user"]["screen_name"] | |
puts text = results[i]["text"] | |
puts icon = results[i]["user"]["profile_image_url"] | |
$growl.notify({ | |
:name => "Tweet", | |
:title => screen_name, | |
:text => text, | |
:icon => icon | |
}) | |
$tweeted[id] = true | |
sleep 1 | |
end | |
} | |
end | |
# Check timeline evry 30 seconds. | |
while true do | |
get_timeline | |
sleep 30 | |
end | |
# vim: ts=2 sw=2 et fdm=marker |
Run
Type following command from command prompt.ruby twitter_notifier.rb
Requierment
Subscribe to:
Posts (Atom)
Followers
Blog Archive
About Me
- snaka
- Tokyo, Japan
- http://iddy.jp/profile/snaka/