counter

20081128

I just made script that fetch twitter timeline and display to Snarl.

It's only Snarl + Ruby. Snarl is system notification tool that like Growl for Mac OS X. You have to download Snarl from here(Snarl :: Homepage). Also need following ruby libraries.

Script

# Simplest twitter client (only for gets)
# twiget.rb
# usage:
# ruby twiget.rb 10
# => friends timeline から 最新10件取得
require 'net/http'
require 'kconv'
require 'rubygems'
require 'snarl'
require 'json'
max_count = ARGV.shift.to_i
Net::HTTP.version_1_2
req = Net::HTTP::Get.new('/statuses/friends_timeline.json')
req.basic_auth "user_id", "password" # user_id, password を自分のものにしてね。
# proxyサーバを適当に変更してね。
Net::HTTP::Proxy('proxy_server', 8080).start('twitter.com') {|http|
res = http.request(req)
if res.code == '200'
result = JSON.parser.new(res.body).parse()
result.length.times do |i|
exit 0 if i >= max_count
puts screen_name = result[i]["user"]["screen_name"]
puts text = result[i]["text"]
Snarl.show_message("Twiget: #{screen_name}", "#{text}", nil, 10)
sleep 1
end
else
Snarl.show_message("Twiget error", "code is #{res.code}", nil, 10)
end
}
view raw gistfile1.rbx hosted with ❤ by GitHub

Usage

You have to change following settings.
  • user_id
  • password
  • proxy_serer
  • proxy port
Command line parameter is ...
  • Num of messages

20081121

Shell script that execute JOBNET on JP1.

Execute JOBNET from termnal.

Usually use java base client in case of excute JOBNET on JP1. So I feel frastration to that hevy weight client. (I think my PC specs not too enough for development usage.) Thats why, I made shell script that execute JP1's JOBNET from telnet terminals. Script is simple. Invoke JOBNET fom ajsentry command.And then wait for a JOBNET. Then parse result and display it.

Script

Script is here.(named 'ajsrun.sh')
#!/bin/sh

JOB_NET=$1

echo "ajsentry -n -w $JOB_NET"
ajsentry -n -w $JOB_NET
echo "ajsshow -l -k -T $JOB_NET"
ajsshow -l -k -T $JOB_NET

Usage

From shell prompt...
ajsrun.sh JOBNET_NAME

Example

Invoke JOBNET '/aaaa/bbbb/JOBNET01'
bash-2.05$ ajsrun.sh /aaaa/bbbb/JOBNET01/
ajsentry -n -w /aaaa/bbbb/JOBNET01/
ajsshow -l -k -T /aaaa/bbbb/JOBNET01/
AJSPATH = /aaaa/bbbb/JOBNET01             net    正常終了         ***          2006/02/14 0:19  2006/02/14  0:20

bash-2.05$

How to parse signed number in COBOL

Conversion table

Here is conversion table.
Digit placehigh digitlow digit
&hx0&hx1&hx2 &hx3&hx4&hx5&hx6&hx7&hx8&hx9
Higher than tenths place digit&h3x0123456789
ones place digit(positive)&h4x@ABCDEFGHI
ones place digit(negative)&h5xPQRSTUVWXY

Converting example

123@+1230
200E-2005
123P-1230
102T-1024

Script that export sequence object from Oracle database

expSeq.sql
set linesize 200
set pagesize 0
set trimspool on
set heading off
set feedback off
spool /tmp/impSeq.sql
select '-- delete sequence' from dual;
select 'DROP SEQUENCE ' || SEQUENCE_NAME || ';' from USER_SEQUENCES;
select '-- create sequence' from dual;
select 'CREATE SEQUENCE ' || SEQUENCE_NAME ||
' START WITH ' || LAST_NUMBER ||
' INCREMENT BY ' || INCREMENT_BY ||
' MINVALUE ' || MIN_VALUE ||
' MAXVALUE ' || MAX_VALUE ||
case CYCLE_FLAG when 'Y' then ' CYCLE' else ' NOCYCLE' end ||
' CACHE ' || CACHE_SIZE || ';'
from USER_SEQUENCES;
select 'quit' from dual;
spool off
quit
view raw gistfile1.sql hosted with ❤ by GitHub
Usage
sqlplus user/pass @expSeq.sql
Example
bash-2.05$ sqlplus mais/mais @expSeq.sql

SQL*Plus: Release 9.2.0.6.0 - Production on 日 Dec 4 01:19:02 2005

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
に接続されました。
-- シーケンスを削除する
DROP SEQUENCE aaaaSEQ;
DROP SEQUENCE bbbbSEQ;
DROP SEQUENCE ccccSEQ;
(省略)
-- シーケンスを生成する
CREATE SEQUENCE aaaaSEQ START WITH 26857 INCREMENT BY 1 MINVALUE 1 MAXVALUE 9999999 CYCLE CACHE 20;
CREATE SEQUENCE bbbbSEQ START WITH 34343 INCREMENT BY 1 MINVALUE 30000 MAXVALUE 49999 CYCLE CACHE 20;
CREATE SEQUENCE ccccSEQ START WITH 33367 INCREMENT BY 1 MINVALUE 30000 MAXVALUE 49999 CYCLE CACHE 20;
(省略)
quit
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Productionとの接続が切断されました。


20081117

Hack GanttProject for mouse wheel behavior

I love GanttProject. Becouse it is most effecient opensource project management tool for me. But I feel discomfort to behavior of mouse wheel. I ofeten use wheel for scrolling. But, in case of GanttProject, mouse wheel assign to zooming operation. I ofeten missoperation and feel frastrations. That's why I made patch and binary for mouse wheel behavior. You can download binary file form following link. This patch changing.
  • You roll up/down wheel on chart area to scroll up/down.
  • You ctrl + roll up/down wheel on chart area to zoom in/out.

Usage

  1. Download "ganttproject.jar" from a link above.
  2. Place "ganttproject.jar" to your GanttProject installed folder. (GanttProject Installed folder)\plugins\net.sourceforge.ganttproject_2.0.0
  3. Launch GanttProject.
I post patch for your feference.
Please see for more info.
http://sumimasen2.blogspot.com/2008/11/hack-ganttproject-for-mouse-wheel.html
view raw readme.txt hosted with ❤ by GitHub
Index: D:/MyProject/GanttProject/ganttproject/src/net/sourceforge/ganttproject/ChartComponentBase.java
===================================================================
--- D:/MyProject/GanttProject/ganttproject/src/net/sourceforge/ganttproject/ChartComponentBase.java (revision 118)
+++ D:/MyProject/GanttProject/ganttproject/src/net/sourceforge/ganttproject/ChartComponentBase.java (working copy)
@@ -290,7 +290,14 @@
protected class MouseWheelListenerBase implements MouseWheelListener {
public void mouseWheelMoved(MouseWheelEvent e) {
- if (isRotationUp(e)) {
+ // Scroll
+ if (!e.isControlDown()) {
+ scrollTreePane(e.getWheelRotation() * 90)
+ return
+ }
+
+ // Zoom
+ if (isRotationUp(e)) {
fireZoomOut()
} else {
fireZoomIn()
@@ -313,6 +320,9 @@
return e.getWheelRotation() < 0
}
}
+
+ protected void scrollTreePane(int amount) {
+ }
protected abstract AbstractChartImplementation getImplementation()
Index: D:/MyProject/GanttProject/ganttproject/src/net/sourceforge/ganttproject/GanttGraphicArea.java
===================================================================
--- D:/MyProject/GanttProject/ganttproject/src/net/sourceforge/ganttproject/GanttGraphicArea.java (revision 118)
+++ D:/MyProject/GanttProject/ganttproject/src/net/sourceforge/ganttproject/GanttGraphicArea.java (working copy)
@@ -973,6 +973,13 @@
setActiveInteraction(new MoveTaskInteractions(e, tasks))
}
}
+
+ /**
+ * Scrolling by relative amount.
+ */
+ protected void scrollTreePane(int amount) {
+ tree.scrollVertical(amount)
+ }
private class NewChartComponentImpl extends ChartImplementationBase
implements ChartImplementation {
Index: D:/MyProject/GanttProject/ganttproject/src/net/sourceforge/ganttproject/GanttTree2.java
===================================================================
--- D:/MyProject/GanttProject/ganttproject/src/net/sourceforge/ganttproject/GanttTree2.java (revision 118)
+++ D:/MyProject/GanttProject/ganttproject/src/net/sourceforge/ganttproject/GanttTree2.java (working copy)
@@ -558,6 +558,24 @@
+ (vbar.isVisible() ? vbar.getWidth() : 0), y - vbar.getValue()
+ 20)
}
+
+ /**
+ * Scroll up/down
+ */
+ public void scrollVertical(int amount) {
+ int originalValue = vbar.getValue()
+
+ int newValue = originalValue + amount
+
+ if (newValue < vbar.getMinimum()) {
+ newValue = vbar.getMinimum()
+ }
+ else if (vbar.getMaximum() < newValue) {
+ newValue = vbar.getMaximum()
+ }
+
+ vbar.setValue(newValue)
+ }
/** Change grpahic part */
public void setGraphicArea(GanttGraphicArea area) {
view raw gistfile1.diff hosted with ❤ by GitHub

20081116

How to post to twitter from Launchy

Instruction

  1. Make a few line code with Ruby.
  2. Use Runny plugin.
That's all. Optionally, Get ruby-snarl gem. So you can recieve notify of result from your script. Here is my Ruby code. (Named 'Twitty.rb')
# Simplest twitter client (only for posts)
require 'net/http'
require 'kconv'
require 'rubygems'
require 'snarl'
require 'json'
user = ARGV.shift
pass = ARGV.shift
status = ARGV.join(" ") || ""
status << "[twitty]"
status_utf8 = status.kconv(Kconv::UTF8, Kconv::SJIS);
Net::HTTP.version_1_2
req = Net::HTTP::Post.new('/statuses/update.json')
req.basic_auth user, pass
req.body = 'status=' + URI.encode(status_utf8)
Net::HTTP.start('twitter.com',80, 'proxy.server_or_addres.here', 8080) {|http|
res = http.request(req)
print res.code
print res.body
if res.code == '200'
result = JSON.parser.new(res.body).parse()
text = result["text"]
posted_at = result["created_at"]
Snarl.show_message('Twitty', "#{text} -- (posted @ #{posted_at})", nil, 10)
else
Snarl.show_message('Twitty', "response {code : #{res.code}, body: #{res.body}}", nil, Snarl::NO_TIMEOUT)
end
}
view raw gistfile1.rbx hosted with ❤ by GitHub
This script have two arguments.
  1. User accout.
  2. Password.
  3. Tweet
You should supply your own user name and password to this script. And tweet is text message. Here is setting of Runny plugin. I was named 'twitty' to this command.

Usage

Invoke Launchy by Ctrl+Space etc.(depend on your setting). Then type 'twitty'. And hit TAB. And type your tweet.

Links

Followers

About Me

Tokyo, Japan
http://iddy.jp/profile/snaka/