View
Theme
Font Style
7pt
8pt
9pt
10pt
11pt
Line Style
100%
110%
120%
130%
140%
Bold Keyword
Default
Inspector
Kkaefer
Eclipse
SQ Light
Lesser
Dark
Cobalt
Monokai
Rubyblue
Night
SQ Dark
Ambiance
Blackboard
Line Num.
Wrap Lines
Preview
Redraw
JS Tab
HTML Tab
CSS Tab
Live Tab
Prev. Tab
Next Tab
Browser
History…
Help
Edit
Settings
Auto Complete
Match Brackets
Match Highlight
Strip Whitespace
Auto Close Brackets
Auto Close Quotes
Show Print Margin
Undo
Redo
Delete
Select Line
Select All
Find & Replace
Find
Find in Repo.
Find Next
Find Previous
Replace Single
Replace All
Wrap Search
Revert
As Template
Diff Revision
Format
Compress
Text
Zen Coding
Indent
Tab Width
1
2
3
4
5
6
7
8
Indent Unit
1
2
3
4
5
6
7
8
Smart Indent
Use Tabs
Visible Tabs
Shift Left
Shift Right
Put Indent
Number
Increment by 1
Decrement by 1
Increment by 0.1
Decrement by 0.1
Increment by 10
Decrement by 10
Simple Math
Comment
Line
Move Up
Move Down
Copy Up
Copy Down
Go to Line…
Remove Line
Next Point
Prev. Point
Help
Share
Login
You can jump to the latest bin by adding
/latest
to your URL
×
z
Find
→
←
⟲
Replace
⊗
All
Replace
String.prototype.trim = function () { return this.replace(/^\s*/, "").replace(/\s*$/, ""); } $(function () { var current = 1; var hist = []; var histpos = 0; function load() { hist = JSON.parse(localStorage.hist); } function save() { localStorage.hist = JSON.stringify(hist); localStorage.histpos = histpos; localStorage.current = current; } function clear() { current = 1; hist = []; histpos = 0; $("#out-inner").html(''); localStorage.clear(); } math = ['abs', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'exp', 'floor', 'log', 'max', 'min', 'pow', 'random', 'round', 'sin', 'sqrt', 'tan']; for (f in math) eval('var ' + math[f] + " = Math." + math[f]); var pi = Math.PI; var e = Math.E; var ln = log; if (localStorage.hist != undefined) { load(); for (var i = 0; i < hist.length; ++i) { got(hist[i]); } } function htmlify(str) { return str.replace(/&/g, '&').replace(//g, '>'); } function scrollToEnd() { $("#out-scroll").scrollTop($("#out-inner").height()); } function echo(msg) { $("#out-inner").append("
" + htmlify(msg.toString()) + "
"); scrollToEnd(); } function message(msg) { $("#out-inner").append((msg.toString()) + "
"); scrollToEnd(); } function beautify(s) { s = s.replace(/(\W|^)pi(\W|$)/g, '$1π$2').replace(/\*/g, '×').replace(/-/g, '−'); return s; } // Handle a lineful. function got(line) { line = line.trim(); if (line === 'quit' || line == 'q') { echo('quit'); message('Good night
, milady
, sir
. It has been a pleasure.'); setTimeout(function () { window.open('', '_self', ''); window.close(); }, 1300); } else if (line == 'help' || line == 'h' || line == '?') { echo('help'); message(''); message("Thank you for asking. Here is how I can serve you:"); message(''); message("Type in an equation and I will calculate it for you. For example:
1 * 2 + 3 / 4
"); message("The following arithmetic operators are available:
+ − * / %
"); message("The following bitwise operators are available:
& | ^ ~ << >> >>>
"); message("You can define new variables, for example:
a = 1 + 2 * 3
"); message("You can also define functions, for example:
f(x) = pow(x, 2)
"); message("The following builtin functions are available:
" + math.join(" ") + "
"); message("The trigonometric functions normally take radians; to use degrees, try:
sin(45deg)
"); message("I also know know the constants
pi
and
e
."); message("You can input hexadecimal values (
0x1234abcd
) and octal values (
0755
)."); message("To convert numbers to hex or oct, try:
100 in hex
or
0x1ff in oct
"); message("Also try the following commands:
clear quit
"); message(''); message("That is all I know. Now, what else could one ask for?"); } else if (line == 'clear') { clear(); } else if (line.match(/^ *$/)) { message("Shall I calculate something for you
, milady
, sir
?"); } else { compute(line); } save(); } var funRegex = /^ *([a-zA-Z$_][a-zA-Z0-9$_]*) *\( *([a-zA-Z$_][a-zA-Z0-9$_]*) *\) *= *(.+)/; function isFunction(what) { return what.match(funRegex); } function handleFunction(what) { return what.replace(funRegex, "$1 = function($2) { return $3 }"); } function insert(resultIndex, formula, result) { var nice = htmlify(beautify(formula)); var resultOrNothing = result != undefined ? " =
" + result + "
" : ""; $("#out-inner").append("
r" + resultIndex + " =
" + nice + "
" + resultOrNothing + "
"); scrollToEnd(); } function compute(expr) { var hex = expr.match(/in hex$/); if (hex) expr = expr.replace(/in hex$/, ''); var oct = expr.match(/in oct$/); if (oct) expr = expr.replace(/in oct$/, ''); echo(expr); var expr = expr.replace(/(\d)deg([^a-zA-Z0-9$_]|$)/, '$1 * (2 * pi / 360)$2'); var actualExpr = handleFunction(expr); try { currentVar = "r" + current; var result = eval(currentVar + "=" + actualExpr); if (abs(result) < 2.5e-16) { result = 0; } } catch (err) { message(err + ". (Terribly sorry
, milady
, sir
.)"); return; } if (isFunction(expr)) insert(current, expr); else { if (hex) result = "0x" + result.toString(16); if (oct) result = "0" + result.toString(8); insert(current, expr, result); } ++current; } $('#in input').keydown(function (e) { var it = $(this); var code = e.keyCode ? e.keyCode : e.which; var what = it.attr('value'); if (code == 13) { it.attr('value', ''); histpos = hist.push(what); got(what); } else if (code == 38) { if (histpos > 0)--histpos; it.attr('value', hist[histpos]); } else if (code == 40) { if (histpos < hist.length - 1)++histpos; it.attr('value', hist[histpos]); } else if (code == 9) {} else { return true; } return false; }); function focus() { $('input').focus(); } function onResize() { var viewportHeight = $(window).height(); var quantized = Math.floor(viewportHeight / 20) * 20; $('#out-scroll').css('max-height', quantized - 100 + "px"); scrollToEnd(); } $(window).resize(onResize); onResize(); focus(); message("Welcome
, milady
, esteemed sir
. Please enter your calculation."); message("Type ‘help’ to get instructions."); });
Zen calculator
>
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { margin:0; padding:0; border:0; outline:0; font-size:100%; vertical-align:baseline; background:transparent; } body { line-height:1; } ol, ul { list-style:none; } blockquote, q { quotes:none; } blockquote:before { content:''; content:none; } blockquote:after { content:''; content:none; } q:before { content:''; content:none; } q:after { content:''; content:none; } :focus { outline:0; } ins { text-decoration:none; } del { text-decoration:line-through; } table { border-collapse:collapse; border-spacing:0; } * { font-family:myriad-pro-1, myriad-pro-2, "Helvetica Neue", sans-serif; font-weight:300; font-size:16px; } body { background:white; width:640px; margin:20px auto; border:1px solid #cccccc; line-height:20px; } #out { padding:20px 0 0 0; } #out-scroll { max-height:240px; overflow:auto; } #out-inner { margin-left:60px; margin-right:20px; } .left { float:left; width:56px; margin-left:-60px; text-align:right; color:#888888; } .echo { color:#888888; } #in { background:#ffffd4; margin-bottom:20px; } #in .left { margin-left:0; width:58px; margin-right:1px; } input { border:none; background-color:transparent; margin:0; padding:0; outline:none; width:540px; } span.result { color:black; } span.result.final { color:green; } span.op, span.var { cursor:pointer; } span.var { color:black; } span.var.new, b { font-weight:600; } ::-moz-selection { background:#cfcfcf; } ::selection { background:#cfcfce; } ::-webkit-selection { background:#cfcecf; } .f, .m { display: none; }
Pop out
Help
About
×
×