tobyaw: (Default)
posted by [personal profile] tobyaw at 11:20pm on 12/02/2014 under ,
Now that Beth is 9½, I figured that it is time for her to learn some simple programming. I started programming when I was a similar age, in Commodore Basic on a VIC-20. With a wealth of languages and learning resources available, I thought back to my childhood enthusiasm for computers, and what I currently find exciting, and decided that Ruby would be a good bet. I use it extensively at work, and generally find it a mood-lightening language to work with.

I figured that it would be useful for her to start off with the groundwork of programming — thinking in terms of input and output, variables, and algorithms. A command-line interface was appealing; I don’t see the value in teaching programming through graphical tools.

Beth spent today working through the first few chapters of the book I bought her, Learn to Program, a child-friendly introduction to programming Ruby that concentrates on teaching programming, rather than just teaching Ruby. She responded with enthusiasm, and is looking forward to more in the morning.

I’m rather disappointed that her school don’t appear to teach any real computing; they are taught to use office apps and web sites, but as far as I can tell, don’t get near to programming. This is a missed opportunity.
location: St Andrews, Scotland
tobyaw: (Default)
posted by [personal profile] tobyaw at 10:35pm on 05/04/2013 under , ,
It struck me that it would be useful to be able to see if any of one’s LiveJournal friends are on App.net, so I wrote a script to do it. Probably not very efficient, but it works.

This depends on people using the same username across different sites, however, so bear in mind that while it may identify a username on App.net that matches one of your LJ friends, it might not be the same person.

Being Ruby, I’d imagine it works on most platforms.

#!/usr/bin/env ruby

require 'net/http'
require 'net/https'
require 'open-uri'

friends = Array.new

ARGV.each do |user|
  open("http://www.livejournal.com/misc/fdata.bml?user=#{user}").readlines.each do |line|
    friends.push line.slice(2..-1).strip if line.match /^>/
  end
end

http = Net::HTTP.new('alpha.app.net', 443)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.start do |connection|
  friends.sort.uniq.each do |friend|
    puts friend if connection.head("/#{friend}").code.to_i.eql? 200
  end
end
tobyaw: (Default)
posted by [personal profile] tobyaw at 07:18pm on 17/11/2012 under , ,
I’ve been programming with Ruby on Rails for some years now; I find Ruby a remarkably satisfying language to programme, and Rails is a productive toolkit which I use primarily for developing internal web apps for various purposes at work.

Up until now I’ve stuck with Rails 2; I have a handful of project that have a fair amount of code, and there hasn’t been a requirement that has merited the work that would go into updating my code to work with Rails 3. But now I’ve started work on a new web app, and it is a decent opportunity to start afresh, take account of what I’ve learned from the previous versions of Rails, and being a project using Rails 3.2.

I spent some time today reading the latest edition of Agile Web Development with Rails; I originally learned Rails with a much earlier edition of this book, so I thought it would be a good starting point for seeing where the current best practices are.

Now, while Kate is downstairs watching Strictly Come Dancing, I’m configuring a server with Phusion Passenger, which appears to be a very straightforward experience. For my previous apps in Rails I’ve tended to use Apache as a load balancer in front of a bunch of Thin web server processes.

It’s rather fun working with a newer version of a development framework; the bulk of it is familiar, but lots of changes, most of which make sense.
location: St Andrews, Scotland
tobyaw: (Default)
posted by [personal profile] tobyaw at 03:03pm on 01/05/2009 under , , ,

Don’t know whether there is an easier way to do this. This script will read a user’s LJ friends list, and check to see whether DW accounts with the same names exist.

#!/usr/bin/ruby

require 'open-uri'

friends = Array.new

ARGV.each do |lj_user|
  open("http://www.livejournal.com/misc/fdata.bml?user=#{lj_user}").readlines.each do |line|
    friends.push line.slice(2...line.length).strip if line =~ /^<|>/
  end
end

friends.sort.uniq.each do |friend|
  puts friend if open("http://users.dreamwidth.org/#{friend}").read !~ /^<h1>Unknown User/
end
location: KY16 8JY
tobyaw: (Default)
posted by [personal profile] tobyaw at 03:03pm on 01/05/2009 under , , ,

Don’t know whether there is an easier way to do this. This script will read a user’s LJ friends list, and check to see whether DW accounts with the same names exist.

#!/usr/bin/ruby

require 'open-uri'

friends = Array.new

ARGV.each do |lj_user|
  open("http://www.livejournal.com/misc/fdata.bml?user=#{lj_user}").readlines.each do |line|
    friends.push line.slice(2...line.length).strip if line =~ /^<|>/
  end
end

friends.sort.uniq.each do |friend|
  puts friend if open("http://users.dreamwidth.org/#{friend}").read !~ /^<h1>Unknown User/
end
location: KY16 8JY
tobyaw: (Default)
Install the Sun developer tools, and install curl. Then to install ruby:
$ curl -O ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.6.tar.gz
$ gunzip ruby-1.8.6.tar.gz
$ tar -xf ruby-1.8.6.tar
$ cd ruby-1.8.6
$ ./configure --without-gcc
$ make
$ su
# PATH=$PATH:/usr/ccs/bin
# export PATH
# make install
# make install-doc


To install gem:
$ curl -O http://rubyforge.rubyuser.de/rubygems/rubygems-0.9.4.tgz
$ gunzip rubygems-0.9.4.tgz
$ tar -xf rubygems-0.9.4.tar
$ cd rubygems-0.9.4
$ su
# PATH=$PATH:/usr/local/bin
# export PATH
# ruby setup.rb


Then to install rails, mongrel etc.:
# gem install rails
# gem install mongrel


(If a gem complains about being unable to build a native extension, try doing PATH=$PATH:/usr/local/bin; export PATH first.)
location: KY16 8JY
tobyaw: (Default)
Install the Sun developer tools, and install curl. Then to install ruby:
$ curl -O ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.6.tar.gz
$ gunzip ruby-1.8.6.tar.gz
$ tar -xf ruby-1.8.6.tar
$ cd ruby-1.8.6
$ ./configure --without-gcc
$ make
$ su
# PATH=$PATH:/usr/ccs/bin
# export PATH
# make install
# make install-doc


To install gem:
$ curl -O http://rubyforge.rubyuser.de/rubygems/rubygems-0.9.4.tgz
$ gunzip rubygems-0.9.4.tgz
$ tar -xf rubygems-0.9.4.tar
$ cd rubygems-0.9.4
$ su
# PATH=$PATH:/usr/local/bin
# export PATH
# ruby setup.rb


Then to install rails, mongrel etc.:
# gem install rails
# gem install mongrel


(If a gem complains about being unable to build a native extension, try doing PATH=$PATH:/usr/local/bin; export PATH first.)
location: KY16 8JY

Links

July

SunMonTueWedThuFriSat
        1
 
2
 
3
 
4
 
5
 
6
 
7
 
8
 
9 10
 
11
 
12
 
13
 
14
 
15
 
16
 
17
 
18
 
19
 
20
 
21
 
22
 
23
 
24
 
25
 
26
 
27
 
28
 
29
 
30
 
31