Parallel Programming Conference : Schedule fixed

Edit

Parallel Programming Confrence has gotten over a hundred of attentions. The schedule is fixed as below:

  • 2010/01/31 13:00 to 18:00
  • at IIJ

I setup the atnd for the banquet about this conference. Come and talk with us!

RubyKaigi 2009 Reject Talk 1

Edit

IMG_1018

I made a presentation at RejectKaigi 2009 in RubyKaigi 2009 day 2. The talk was about Rubigraph which I created a year ago.

Slide:

Video:

Sample Code:


Enjoy!

Ditz on GitHub Page

Edit

I made it work Ditz on GitHub page, displaying Ditz contents like releases, tasks on GitHub site. Here’s how to do it:

1. create a GitHub page

follow the instruction in GitHub Pages::Project Pages to create your project page. In short, create origin/gh-pages tree and push it to GitHub. It takes for up to ten minutes if you create it first time, so prepare for the next step.

Example: github.com/mootoh/milpon@gh-pages

2. generate static contents with Ditz

generate files of releases and tasks statically by ditz html [output-dir]. Then `checkout gh-pages && add output-dir && commit && push origin gh-pages“.

3. That’s it!

You’ve done! So easy, isn’t it?

Example: mootoh::milpon::ditz

ToDo

  • Automation : use cron to publish ditz stuff periodically
  • web interface to interact tickets

Happy Ditz & GitHub hacking!

IDAvailability

Edit

I made a small web application, IDAvailability that checks how available the entered ID is in the world.

Web services

I added only 8 web services at the begenning. However, web service information is stored in wedata, a wiki-like data store that everyone can edit, everybody can add web services to it (for now, 28 web services has been added). Database is here.

You can add a web service from Create New Item, and enter following information.

  • name : name of web service (any)
  • urlToCheck : URL embedded #{ID} variable (like http://nantokakanto.ka/user/#{ID})
  • condition : a XPath expression to check whether the ID is used when the server response is HTTP 200 , not ”404 Not Found” while accessing urlToCheck. (for example, see flickr)

Code

ToDo

  • Move check functions to client-side (retrieving HTML via Ajax, examining XPath…)
  • Better looks

Try and enjoy it, also add your favorite web service missing.

Gainer++ – use Gainer from C++

Edit

I wrote a C++ wrapper library for Gainer, based on its Ruby library (gainer-ruby). The code is submitted to CodeRepos as Gainer++, here.

So Far

It supports following functions:

  • mode switch by constructor
  • analog inputs
  • digital inputs

It has some examples, like blinking LED on Gainer I/O module (gainer-led.cc).


Feel free to use, modify, and commit to it.

user_timeline_to_ical

Edit

What is this ?

A simple Ruby script that generates iCalendar format from Twitter user_timeline.

Download

user_timeline_to_ical.rb

Requirements

following gems installed:

  • json
  • icalendar

How to use

simply type

ruby user_timeline_to_ical.rb [your_screen_name]

to print out recent 20 events in iCalendar format to stdout.

Redirect its output to a file, then import it with iCal or Google Calendar.

Screenshot

from iCal: Twitter to iCalendar-01

from Google Calendar: Twitter to iCalendar-02

Future …

I’m developing a web service that serves iCalendar feed (by sending direct message to tracking bot). You will subscribe its URL to see your past behaviors at some time.

Code

Try it !

#
# create iCalendar from recent 20 user_timeline.
#
# usage
#   ruby user_timeline_to_ical.rb [username] > some.ics
#
require 'rubygems'
require 'json'
require 'icalendar'
require 'uri'
require 'open-uri'
require 'kconv'
require 'nkf'
require 'logger'
 
KCODE = 'u'
 
# XXX:
#   quick fix to avoid charset crash
module Icalendar
  class Component < Icalendar::Base
    def print_properties
      s = ""
 
      @properties.each do |key,val| 
        # Take out underscore for property names that conflicted
        # with built-in words.
        if key =~ /ip_.*/
          key = key[3..-1]
        end
 
        # Property name
        unless multiline_property?(key)
           prelude = "#{key.gsub(/_/, '-').upcase}" +
 
           # Possible parameters
           print_parameters(val) 
 
           # Property value
           value = ":#{val.to_ical}" 
           escaped = prelude + value.gsub("\\", "\\\\").gsub("\n", "\\n").gsub(",", "\\,").gsub(";", "\\;")
           #escaped = value
           #s << escaped.slice!(0, MAX_LINE_LENGTH) << "\r\n " while escaped.size > MAX_LINE_LENGTH # XXX : quick fix to avoid charset crash
           s << escaped << "\r\n"
           s.gsub!(/ *$/, '')
         else 
           prelude = "#{key.gsub(/_/, '-').upcase}" 
            val.each do |v| 
               params = print_parameters(v)
               value = ":#{v.to_ical}"
               escaped = prelude + params + value.gsub("\\", "\\\\").gsub("\n", "\\n").gsub(",", "\\,").gsub(";", "\\;")
               s << escaped.slice!(0, MAX_LINE_LENGTH) << "\r\n " while escaped.size > MAX_LINE_LENGTH
               s << escaped << "\r\n"
               s.gsub!(/ *$/, '')
            end
         end
      end
      s
    end
  end
end
 
class UserTimeLine
  attr_accessor :id, :since
  URL = 'http://twitter.com/statuses/user_timeline/'
 
  def initialize(id)
    @id = id
    #@log = Logger.new('debug.log')
  end
 
  def get(url)
    JSON.parse(open(url).readlines.join).sort { |a, b| a['id'] <=> b['id'] }
  end
 
  def url(*arg)
    url = URL + @id + '.json'
    return url if arg.empty?
 
    hash = arg[0]
    args = {}
 
    args['page'] = hash[:page] if hash[:page]
    if hash[:since]
      if String == hash[:since].class 
        args['since'] = URI.escape(hash[:since].split.join('+'))
      else # should be Number
        args['since_id'] = hash[:since]
      end
    end
    arg = args.collect { |k, v| [k, v].join('=') }.join('&')
 
    url + '?' + arg
  end
 
  def to_ical
    msgs = get(url).collect {|x| [x['text'], x['created_at']]}
    cal = Icalendar::Calendar.new
 
    (msgs.size-1).times do |i|
      cal.event do
        dtstart  DateTime.parse(msgs[i][1]).to_ical(true)
        dtend    DateTime.parse(msgs[i+1][1]).to_ical(true)
        summary  msgs[i][0]
      end
    end
 
    cal.to_ical
  end
end
 
 
utl = UserTimeLine.new(ARGV.shift)
print NKF.nkf('-w -Lw', utl.to_ical)

SocketReaderPatch

Edit

SocketReaderPatch

What is SocketReaderPatch ?

A Coustom Quartz Composer Patch that recieves strings from TCP Socket.

Download

Install

Copy SocketReaderPatch.plugin into /Library/Graphics/Patch .

How to use

Open QuartzComposer, find SocketReader from the Patch Library list (type “Socket” in Search in Libraries field to search it) .

Then drag SocketReader into right pane, and play it. SocketReader listens port number 12345 in default. Make some client application and write UTF-8 strings into the socket, and Quartz Composer will show that strings.

Example

Simple Example

ScreenCast !

Note

  • Very buggy. If two or more sockets are connected, CPU usage will be so high.
  • To change the port number, edit port_ variable in SocketReaderPatch.m.

Reference

I used Quartz Composer Custom Patch Xcode template from fdiv.net:Xcode Template for Custom Quartz Composer Patches. (Thanks!)

In order to play with socket in Cocoa, O’Reilly Network::mac devcenter::Networking in Cocoa was pretty helpful.

Motivation

I came up to an idea that IRC messages flow beautifully by using QuartzComposer, in RubyKaigi2007 . To push dynamic text into QuartzComposer, it seemed to be only RSS feed out there.

License

CC : Attribution-NonCommercial-ShareAlike, because above Xcode template claims that license.

Contact

Any feedbacks are welcome, mail me.