# Encoding: UTF-8

[{beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\n\nprint \" = \" + $stdin.read.gsub(/[$€£]/, '').scan(/((?:\\b|-)[0-9]+(?:\\.[0-9]+)?)\\b/).inject(0.0) { |t,s| t + s[0].to_f() }.to_s.sub(/.0+\\z/, '')",
  fallbackInput: "line",
  input: "selection",
  keyEquivalent: "^C",
  name: "Add Numbers in Line / Selection",
  output: "afterSelectedText",
  uuid: "D6EEB6EA-77E9-11D9-B36F-000D93589AF6"},
 {beforeRunningCommand: "nop",
  command: "bc <<<\"obase=16;$(cat)\"|tr -d \\\\n",
  fallbackInput: "word",
  input: "selection",
  keyEquivalent: "^C",
  name: "Decimal to Hex",
  output: "replaceSelectedText",
  uuid: "6E8B4CDA-07CD-4BFA-ABFE-5ABA14F35B8A"},
 {beforeRunningCommand: "nop",
  command: "bc <<<\"obase=8;$(cat)\"|tr -d \\\\n",
  fallbackInput: "word",
  input: "selection",
  keyEquivalent: "^C",
  name: "Decimal to Octal",
  output: "replaceSelectedText",
  uuid: "93992270-EA57-4AE0-BF91-16C9110A41E1"},
 {beforeRunningCommand: "nop",
  command: 
   "printf \" = %s\" `{ tr -d ,; echo; } | bc -l`| perl -pe 's/(\\.[^0]+)0+$|\\.0+$/$1/'",
  fallbackInput: "line",
  input: "selection",
  keyEquivalent: "^C",
  name: "Evaluate Line / Selection",
  output: "afterSelectedText",
  uuid: "93A395CC-77E8-11D9-B5A8-000D93589AF6"},
 {beforeRunningCommand: "nop",
  command: 
   "printf \"%s\" `{ tr -d ,; echo; } | bc -l`| perl -pe 's/(\\.[^0]+)0+$|\\.0+$/$1/'",
  fallbackInput: "line",
  input: "selection",
  keyEquivalent: "^C",
  name: "Evaluate and Replace Expression",
  output: "replaceSelectedText",
  uuid: "D1DFE75D-EAAD-4662-8F1F-F5556402054B"},
 {beforeRunningCommand: "nop",
  command: "printf \"%.0f\" `{ tr -d ,; echo; } | bc -l`",
  fallbackInput: "line",
  input: "selection",
  keyEquivalent: "^C",
  name: "Evaluate and Replace Expression (rounded)",
  output: "replaceSelectedText",
  uuid: "A8369DD4-4424-4A64-B0B1-FB8BD7D8E02C"},
 {beforeRunningCommand: "nop",
  command: "bc <<<\"ibase=16;$(tr '[a-z]' '[A-Z]')\"|tr -d \\\\n",
  fallbackInput: "word",
  input: "selection",
  keyEquivalent: "^C",
  name: "Hex to Decimal",
  output: "replaceSelectedText",
  uuid: "C688B837-D48A-4088-9374-F93E7B4CCD3C"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\nrequire 'cgi'\nrequire 'net/http'\nrequire ENV['TM_SUPPORT_PATH'] + '/lib/exit_codes'\nrequire ENV['TM_SUPPORT_PATH'] + '/lib/progress.rb'\n\nquery = CGI::escape(STDIN.read)\nabort if query.empty?\n\nTextMate.call_with_progress(:message => 'Querying Google…') do\n  response = Net::HTTP.get('www.google.com', '/search?q=' + query)\n  if response =~ /<b>.*? = (.*?)<\\/b>/\n    answer = $1\n    answer.gsub!(/<sup>(.+?)<\\/sup>/, '^\\1') # Prefix exponents\n    answer.gsub!(/<.+?>/, '')\n    answer.gsub!('&#215;', '×')\n    answer.gsub!(/(\\d+) (?=\\d{3})/, '\\1,') # Turn 10 000 into 10,000\n    print answer\n  else\n    TextMate.exit_show_tool_tip 'Invalid calculation'\n  end\nend",
  fallbackInput: "line",
  input: "selection",
  keyEquivalent: "^C",
  name: "Send Line / Selection to Google Calculator",
  output: "replaceSelectedText",
  uuid: "BA9536B4-5A7E-46D2-A268-E0ADAB9782BC"},
 {beforeRunningCommand: "nop",
  command: 
   "printf \" = %s\" `{ tr -d ,|tr -cs '[0-9.]' ' '|perl -pe 's/([0-9.]+) (?=[0-9.])/$1-/g'; echo; } | bc -l`| perl -pe 's/(\\.[^0]+)0+$|\\.0+$/$1/'",
  fallbackInput: "line",
  input: "selection",
  keyEquivalent: "^C",
  name: "Subtract Numbers in Line / Selection",
  output: "afterSelectedText",
  uuid: "F1541E0F-77EB-11D9-B807-000D93589AF6"}]
