Skip to content

Instantly share code, notes, and snippets.

# multiplication_table
STDOUT.sync = true
def multiplication_table n, msg = '', decorate = false
len = (n * n).to_s.length + 1
head = decorate ? " #{'=' * len * n}\n" : ''
body = " #{msg}\n" << head <<
(1..n).collect{|j| (1..n).collect{|i| "%#{len}s" % (i*j)}.join + "\n"}.join <<
head << "\n"
end
require 'ostruct'
module RubyInstaller
module Version
unless defined?(MAJOR)
MAJOR = 3
MINOR = 0
REVISION = 0
end
end
# This is a replay to Fela's question:
# http://gist.github.com/452089
#
# Look at Shoes manual, The Rules of Shoes
# - Shoes Tricky Blocks
# - Block Redirection
#
# http://shoes.heroku.com/manual/Rules.html
#
# If you'd like to add all outputs of addparas into the flow slot you defined
# A shoes script (www.shoooes.net) to split a Wordpress WXR file into
# smaller files for easier importing to Wordpress
# Copyright Cecil Coupe (2008)
# ccoupe@cableone.net
# Use it anyway you like. An email to author is appreciated.
#
# One could change all the @console.puts (str) to @console.contents << str+'\n'
# One could get really tired to doing that a lot of times.
Shoes::Para.class_eval do
def puts(str)
require '../lib/green_shoes'
DATA = %w{ place plan plant plot face race rails ruby train trouble double }
MSG = "Enter a search."
Shoes.app title: "Search sample", width: 300, height: 400 do
def search input
input.empty? ? [] : DATA.select{|w| w.include? input}
end
edit_line width: 300 do |el|
require '../lib/green_shoes'
class Kensho < Shoes
url '/', :index
url '/validate', :validate
def index
stack do
flow do
para "kensho"
#
# Shoes Clock by Thomas Bell
# posted to the Shoes mailing list on 04 Dec 2007
# Original code for Red Shoes is: https://github.com/shoes/shoes/blob/master/samples/good-clock.rb
# The following is a little bit modified for Green Shoes
#
require '../lib/green_shoes'
Shoes.app :height => 260, :width => 250 do
@ashbb
ashbb / creatures.rb
Created February 21, 2011 13:53
Assignment 2 for Ruby Metaprogramming course at RubyLearning.org
# creatures.rb
class IndustrialRaverMonkey < Creature
life 46
strength 5
end
class DwarvenAngel < Creature
life 54
strength 8
@ashbb
ashbb / PPIDdata.txt
Created March 12, 2011 01:45
A solution for "Problem in script help (shoes)" posted by Lark Work in ruby-talk ML.
ashbb,shoes,010-223-3356,2011.3.11,Tokyo,Japan
require 'green_shoes'
require_relative './orgaan'
include OrgaanGui
Shoes.app title:"Shu Ha Ri",width: 1280, height: 720 do
background khaki, height: 2000
@m=[]
fwin1 = flow width: 0.5, height: 0.3 do
para "In onderstaande lijst kunt u een keuze maken