A page for discussing [Twig] [Stu] 2008-11-14 Numbers and checksums on this page current as of this writing. ---- Preemptive Q&A: ====== Q: Isn't it dangerous to run code from strange places?<
> 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] ====== 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 & ====== ---- !!!!!! %| enter categories here |% !!!!!!