This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Back up your iTunes library to S3 | |
| git clone git://github.com/sstephenson/mackerel.git | |
| ruby -rubygems mackerel/examples/itunes_backup.rb amazon-s3://YOUR_ACCESS_KEY_ID:YOUR_SECRET_ACCESS_KEY@s3.amazonaws.com/YOUR_BUCKET_NAME/itunes.mackerel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def extract_options_from(arguments) | |
| arguments.values_at *(indexes_for(arguments) - argument_indexes_for(arguments)) | |
| end | |
| def extract_arguments_from(arguments) | |
| arguments.values_at *argument_indexes_for(arguments) | |
| end | |
| def indexes_for(arguments) | |
| (0...arguments.length).to_a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var BackgroundIteration = Class.create({ | |
| initialize: function(iterator, produceNextValue) { | |
| this.iterator = iterator; | |
| this.produceNextValue = produceNextValue; | |
| this.callbacks = []; | |
| this.results = []; | |
| this.next = this.next.bind(this); | |
| this.next.defer(); | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| H:\Projects\sprockets>rake | |
| 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 | |
| Started | |
| .E.F.EFFFFF..........E.E.EEEFFE......F............ | |
| Finished in 2.922 seconds. | |
| 1) Error: | |
| test_save_to(ConcatenationTest): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "tcl" | |
| module Tcl | |
| class ExprEvaluator | |
| def initialize | |
| @interp = Tcl::SafeInterp.new | |
| commands = @interp.list_to_array(@interp._!(:info, :commands)) - %w(info set unset rename expr) | |
| (commands + %w(rename)).each { |command| @interp._!(:rename, command, "") } | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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] |
NewerOlder