Skip to content

Instantly share code, notes, and snippets.

View bovine's full-sized avatar

Jeff Lawson bovine

View GitHub Profile
bovine@calek:~/>cat foo.tcl
package require yajltcl; # available from https://github.com/flightaware/yajl-tcl
set json "\{\"update\":23213,\"msg\":\"qwerty\"\}\n\{\"update\":454323,\"msg\":\"asdfg\"\}"
foreach line [split $json "\n"] {
array set data [yajl::json2dict $line]
parray data
puts "----"
}

Keybase proof

I hereby claim:

  • I am bovine on github.
  • I am bovine (https://keybase.io/bovine) on keybase.
  • I have a public key whose fingerprint is F117 F1F0 3C59 15D1 8F27 0AFA F76A 6427 3A94 BB4D

To claim this, I am signing this object:

@bovine
bovine / tpool_threxit_bug2.tcl
Created November 11, 2016 18:20
tpool::post hangs if the maximum number of workers has already been reached, but they have all exited already
#!/usr/local/bin/tclsh
package require Thread
# initialize the thread pool
set mypool [tpool::create -minworkers 1 -maxworkers 5]
# queue up something that exits the thread.
# this will be unable to process more than 5 events because all of the workers have gone away.
for {set i 0} {$i < 10} {incr i} {
@bovine
bovine / tpool_threxit_bug1.tcl
Created November 11, 2016 18:17
tpool::release hangs if any of the thread pool's workers have exited
#!/usr/local/bin/tclsh
package require Thread
# initialize the thread pool
set mypool [tpool::create -minworkers 1 -maxworkers 5]
# queue up something that exits the thread
tpool::post $mypool "puts \"hello\"; thread::exit"
@bovine
bovine / tpool_nowait_bug.tcl
Created November 11, 2016 17:11
tpool::post -nowait does not ever create more than 1 worker thread
#!/usr/local/bin/tclsh
package require Thread
set threadstart {
puts "thread started"
tsv::incr sharedData threadCount
}
#!/usr/local/bin/tclsh8.6
package require http
package require autoproxy
package require tls
proc init1 {} {
set http_proxy_host "proxy"
@bovine
bovine / gist:15c350d044325a93d5cb
Created July 15, 2015 22:25
memory leak in tcl 8.6.4
#!/usr/local/bin/tclsh
proc doit {newkey} {
global myarray
global clocknow
# store a new value into the array
set myarray($newkey) $clocknow
diff -uwr mod_rivet.orig/Makefile mod_rivet/Makefile
--- mod_rivet.orig/Makefile 2014-03-12 18:03:28.000000000 -0500
+++ mod_rivet/Makefile 2014-03-12 18:03:52.000000000 -0500
@@ -16,7 +16,7 @@
LIB_DEPENDS= libitcl.so:${PORTSDIR}/lang/itcl
USE_APACHE= 22+
-USE_AUTOTOOLS= aclocal automake libtool libtoolize
+USE_AUTOTOOLS= aclocal libtool libtoolize autoheader automake autoconf
USE_LDCONFIG= ${PREFIX}/lib/rivet
#include <boost/interprocess/managed_mapped_file.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/containers/string.hpp>
#include <boost/flyweight.hpp>
#include <boost/flyweight/no_tracking.hpp>
#include <boost/flyweight/hashed_factory.hpp>
using namespace boost::flyweights;
using namespace boost::container;
@bovine
bovine / web-skins-classic-views-options.php.diff
Created April 1, 2012 06:23
Zoneminder 1.25.0 patch: display configuration help in a tooltip or alert box rather than a new window. make configuration radio buttons easier to click by using labels.
--- web/skins/classic/views/options.php (revision 3648)
+++ web/skins/classic/views/options.php (working copy)
@@ -211,10 +211,13 @@
{
$shortName = preg_replace( '/^ZM_/', '', $name );
$optionPromptText = !empty($OLANG[$shortName])?$OLANG[$shortName]:$value['Prompt'];
+
+ $optionHelpText = !empty($OLANG[$shortName])?$OLANG[$shortName]:$config[$name]['Help'];
+ $optionHelpText = preg_replace( "/~~/", "\n", $optionHelpText );
?>