Version 15 of Twigging

Updated 2008-11-16 00:22:51 by Stu

A page for discussing Twig

Stu 2008-11-16 Numbers and checksums on this page current as of their writing.


Preemptive Q&A:

Q: Isn't it dangerous to run code from strange places?<<br>>
A: The danger can be averted by checking the code then calculating
a checksum and verifying the code against the checksum before running it.
Hence, Twig.

Q: Ok, there's this page of 'twigs'.
What if someone alters the code then alters the checksum in that big bundle of twigs?
A: There is a checksum against the entire block (or 'bundle', if you prefer).

Q: What if someone alters that as well?
A: I keep the twig of that block on my site as well; you can check against that.

Q: Can I trust you?
A: I'd like to think so.

Q: I don't know ...
A: You can save the twig(s)/check the code yourself.

Twig

Get Twig from Twig or my site. If you're too lazy to copy & paste then wget and a bit of awk can do it. General use instructions on the Twig page.

How to use the twigs on the Twigs page (if you're not using TkTwig).
These examples assume that Twig is installed in your path as 'twig'.

# run #111
$ twig 21912 4 | awk 'NR==111 {print}' | twig -c - | wish &

# verify twigs, then run #111
$ twig 21912 2 | twig -c - | awk 'NR==111 {print}' | twig -c - | wish &

TkTwig

Get TkTwig from TkTwig or my site. Use it or Twig to get the twigs on the Twigs page or get them some other way. Find some new ones and share!

If you're really lazy, this will pull both TkTwig and the Tcler's Wiki twigs, combine and run.

(twig 21912 2 | twig -c - | awk 'NR==310 {print}' | twig -c -; echo 'set ::cow {'; twig 21912 2 | twig -c -; echo '};tktwig::loadBundle +::cow') | wish &

Or this:

(twig 21912 2 | twig -c - | awk 'NR==310 {print}' | twig -c -; twig 21912 2 | twig -c -) | wish -b - &

Mashups

Interesting results can be achieved by combining pages.

This combines the Starfield and Spirograph pages. I've found that Starfield can be mixed with many others.

(twig 21912 2 | twig -c - | awk 'NR==279 {print}' | twig -c -;twig 21912 2 | twig -c - | awk 'NR==276 {print}' | twig -c -) | wish &

These examples are long because they include the checking of the big twig bundle as well as each twig being used. The above could also be done as follows, without any checking. Be careful!

(twig 10100 1; twig 4206 2) | wish & 

TwigSrc

Augment source with Twig

# twigsrc.tcl
namespace eval twig {
	variable sourceMap; array set sourceMap {}
	rename ::source ::_source; interp alias {} ::source {} [namespace current]::src
	proc src {fn args} { variable sourceMap
		if {[info exists sourceMap($fn)]} { uplevel 1 [exec twig -c - <<$sourceMap($fn)]
		} else { uplevel 1 _source $fn {*}$args }
	}
	proc addSrc {fn twig} { variable sourceMap; set sourceMap($fn) $twig }
}
###

TwigSrc for card_img (14629)

# card_img.tcl twigsrc
twig::addSrc card_img.tcl {14629 1 C1C8795ED7BD3C21E742DE426FCE0AB2}
#

Twig for Spider Solitaire (11317)

# Spider Solitaire (11317) twig
21913 7 2710B2DEC0CAAFFC29B0B2AD6023A856
21913 8 A7920F2523921D0381AB4F21FEF3793F
11317 1 F267A7044616795D85B4D9EF7A4177DA

Twig for Once In A Lifetime (11193)

# Once In A Lifetime (11193) twig
21913 7 2710B2DEC0CAAFFC29B0B2AD6023A856
21913 8 A7920F2523921D0381AB4F21FEF3793F
11193 2 55F6103995FAEF1599178DBB039474BE

Twig for TriPeaks Solitaire (13092)

# TriPeaks Solitaire (13092) twig
21913 7 2710B2DEC0CAAFFC29B0B2AD6023A856
21913 8 A7920F2523921D0381AB4F21FEF3793F
13092 1 7C33DD1A1196BBE29508A1A1D782B472

Twig for scat (8810)

# scat (8810) twig
21913 7 2710B2DEC0CAAFFC29B0B2AD6023A856
21913 8 A7920F2523921D0381AB4F21FEF3793F
8810 1 797608C2FFCD7F0979AA28428E26358A

Run Spider Solitaire (9).
For the others, replace 9 with 10, 11 or 12.

$ twig 21913 9 | twig -c - | wish &

Procs from the Aether

$ twig -g -n 1923 1
1923 1 81B4E2D287A7D79CE4BA7550A7BE01EB {} K

% K a b
invalid command name "K"

% set ::auto_index(K) {{*}[exec twig -c - <<[concat 1923 1 81B4E2D287A7D79CE4BA7550A7BE01EB]]}

% K a b
a

% info procs K
K

% rename K {}

% info procs K

% K x y 
x

argv0/[info script]

argv0/[info script] fooler

# argv0/[info script] fooler
set ::argv0 [info script]

Twig for An i15d date chooser (1816)

# An i15d date chooser (1816)
21913 15 CBC25E3921608AE2967A5C36F52540F9
1816 3 18C41EA8CE93DF04147D3E70B8111AC3

Run An i15d date chooser (1816)

$ twig 21913 16 | twig -c - | wish &

OS File Locations

I'd like to run A little fortune teller (9425) but I don't run the same OS as the original author so my fortunes file is in a different location than specified in the code. To make this work, I've split the original code block into two blocks: the first sets the name of the fortunes file and the second is the rest of the code. All I need now is a twigged line of code setting the name of the fortunes file.

Fortunes file on OpenBSD

# fortunes file on OpenBSD
set filename /usr/share/games/fortune/fortunes

These done a bit differently, more ''manually'.

First, gather some info

# standard fortune file
eve$ twig -g 9425 1   
9425 1 D990C81E4F6FD15F00BA3553A5CF8575
# fortune prog
eve$ twig -g 9425 2 
9425 2 2149D71A722942130CB7E7EE1529FBB4
# openbsd fortune file
eve$ twig -g 21913 0      
21913 0 169172A3CE0D0C7A9D2E8AE62EC42601

Run A little fortune teller (9425) (standard)

$ (twig -s D990C81E4F6FD15F00BA3553A5CF8575 9425 1; twig -s 2149D71A722942130CB7E7EE1529FBB4 9425 2) | wish &

Run A little fortune teller (9425) (OpenBSD)

$ (twig -s 3A324AB59E40E456134313F8263993BC 21913 18 ; twig -s 2149D71A722942130CB7E7EE1529FBB4 9425 2) | wish &

enter categories here