Random Ruby

I found some old random ruby scripts from ages ago.

This is a script to create 1,000 hidden services. Apparently I ran it as create_hidden_serv.rb >> torrc


start_port = 10000;
 datadir = "~/.tor";
 end_port = 11000;

until start_port == end_port do
 puts "HiddenServiceDir #{datadir}/hidserv/#{start_port}
 HiddenServicePort #{start_port}{start_port}";
 #puts "#{start_port}";
 start_port += 1;

Create a tag cloud based on a body of text.

 #!/usr/bin/ruby -w

# Usage: tagme.rb /path/to/file

require 'rubygems'
 require 'classifier'
 lsi = Classifier::LSI.new # start fresh

# read the file into an array
 f = File.open("#{ARGV[0]}")
 textarray = f.readlines
 textarray.each { |item| item.downcase! }

# add each word into the index
 textarray.each { |item| lsi.add_item item }

# build the index

# classify the index
 # this really wants to be something else, like lsi.items, or some
 # reference to the index itself
 lsi.classify textarray

# spit out a list of words
 puts lsi.items

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s