Skip to content

Instantly share code, notes, and snippets.

View let.tcl
#!/usr/bin/env TEST=1 tclsh
proc let {block args} {
try {
set captured_vars [uplevel [list capture [block args]]]
set all_var_names [uplevel {info vars}]
foreach var [block args] value $args {
uplevel [list catch [list unset $var]]
uplevel [list set $var $value]
View git-track
branch=$(git branch 2>/dev/null | grep ^\*)
[ x$1 != x ] && tracking=$1 || tracking=${branch/* /}
git config branch.$tracking.remote origin
git config branch.$tracking.merge refs/heads/$tracking
echo "tracking origin/$tracking"
View gist:42974
require "tcl"
module Tcl
class ExprEvaluator
def initialize
@interp =
commands = @interp.list_to_array(@interp._!(:info, :commands)) - %w(info set unset rename expr)
(commands + %w(rename)).each { |command| @interp._!(:rename, command, "") }
View gist:64431
C:/ruby/bin/ruby -Ilib;test "C:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/rake_test_loader.rb" "test/test_concatenation.rb" "test/test_environment.rb" "test/test_helper.rb" "test/test_pathname.rb" "test/test_preprocessor.rb" "test/test_secretary.rb" "test/test_source_file.rb" "test/test_source_line.rb"
(in H:/Projects/sprockets)
Loaded suite C:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/rake_test_loader
Finished in 2.922 seconds.
1) Error:
View gist:70357
var BackgroundIteration = Class.create({
initialize: function(iterator, produceNextValue) {
this.iterator = iterator;
this.produceNextValue = produceNextValue;
this.callbacks = [];
this.results = []; =;;
View gist:72527
def extract_options_from(arguments)
arguments.values_at *(indexes_for(arguments) - argument_indexes_for(arguments))
def extract_arguments_from(arguments)
arguments.values_at *argument_indexes_for(arguments)
def indexes_for(arguments)
View gist:105760
# Back up your iTunes library to S3
git clone git://
ruby -rubygems mackerel/examples/itunes_backup.rb amazon-s3://
View gist:107031
var DateHelper = {
timeAgoInWords: function(from) {
return this.distanceOfTimeInWords(new Date(), from);
distanceOfTimeInWords: function(to, from) {
var distance_in_seconds = ((to - from) / 1000);
var distance_in_minutes = (distance_in_seconds / 60).floor();
if (distance_in_minutes <= 0) return "less than a minute";
View harpers.rb
# A library for downloading issues of Harpers from the archives.
# To use, log in to the archives from your web browser. Then set the
# HARPERS_ARCHIVE_COOKIE environment variable to the value of the
# "archive" cookie, which you can find by visiting the following URL while on
# the Harpers website:
# javascript:prompt("HARPERS_ARCHIVE_COOKIE",document.cookie.match(/(?:;|^)\s*archive=(.+?)(?:;|$)/)[1])
# Example:
View gist:109704
module Tcl
class << self
# Returns a well-formed Tcl list from the given array of strings.
def array_to_list(array) { |element| string_to_word(element.to_s) }.join(" ")
# Returns a well-formed Tcl word from the given string.
def string_to_word(string)
should_be_braced?(string) ? brace_string(string) : escape_string(string)