Most viewed JavaScript recipes http://code.activestate.com/recipes/langs/javascript/views/2017-06-06T03:48:09-07:00ActiveState Code RecipesPassword Grabber Javascript (JavaScript)
2008-10-26T12:00:08-07:00TheMachineCharmerhttp://code.activestate.com/recipes/users/4167676/http://code.activestate.com/recipes/576542-password-grabber-javascript/
<p style="color: grey">
JavaScript
recipe 576542
by <a href="/recipes/users/4167676/">TheMachineCharmer</a>
(<a href="/recipes/tags/dom/">dom</a>, <a href="/recipes/tags/password/">password</a>, <a href="/recipes/tags/security/">security</a>).
Revision 2.
</p>
<p>This is script coded for FUN.
You can get information in the hidden fields of web pages.</p>
nicerest: pretty-print JSON output (JavaScript)
2011-01-18T22:59:12-08:00Trent Mickhttp://code.activestate.com/recipes/users/4173505/http://code.activestate.com/recipes/577549-nicerest-pretty-print-json-output/
<p style="color: grey">
JavaScript
recipe 577549
by <a href="/recipes/users/4173505/">Trent Mick</a>
(<a href="/recipes/tags/curl/">curl</a>, <a href="/recipes/tags/json/">json</a>, <a href="/recipes/tags/node/">node</a>, <a href="/recipes/tags/nodejs/">nodejs</a>, <a href="/recipes/tags/rest/">rest</a>).
Revision 3.
</p>
<p>Save this to "nicerest", <code>chmod +x</code>-it, and pipe your REST API <code>curl</code> calls through this for nicer output. It will notice HTTP headers (curl's <code>-i</code> option) and skips those before attempting to pretty-print the following JSON.</p>
<p>Note: This is currently using node 0.2. I should update for 0.3 changes (I think <code>process.openStdin</code> changed).</p>
Mandelbrot Fractal using HTML5 Canvas (JavaScript)
2012-12-28T01:01:09-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577277-mandelbrot-fractal-using-html5-canvas/
<p style="color: grey">
JavaScript
recipe 577277
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>).
Revision 3.
</p>
<p>Mandelbrot Fractal using HTML5 Canvas.
(Do not forget to change file extension to HTML after downloading it.)</p>
The Matrix Effect (JavaScript)
2009-07-28T10:13:20-07:00Panda Moniomhttp://code.activestate.com/recipes/users/4171270/http://code.activestate.com/recipes/576861-the-matrix-effect/
<p style="color: grey">
JavaScript
recipe 576861
by <a href="/recipes/users/4171270/">Panda Moniom</a>
(<a href="/recipes/tags/dynamic_drive/">dynamic_drive</a>, <a href="/recipes/tags/effect/">effect</a>, <a href="/recipes/tags/javascript/">javascript</a>, <a href="/recipes/tags/matrix/">matrix</a>, <a href="/recipes/tags/text/">text</a>).
</p>
<p>This code is and opensource code from Dynamic Drive.</p>
<p>Add the Matrix effect to any text. I have displayed the code for and entire demo page. Any text that you want to have the Matrix effect, put it inside <div id="matrix> and </div>.</p>
Post code to Pastebin.com (JavaScript)
2010-12-06T17:56:41-08:00Nathan Rambeckhttp://code.activestate.com/recipes/users/4171896/http://code.activestate.com/recipes/577489-post-code-to-pastebincom/
<p style="color: grey">
JavaScript
recipe 577489
by <a href="/recipes/users/4171896/">Nathan Rambeck</a>
(<a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/pastebin/">pastebin</a>).
</p>
<p>This is an updated version of another recipe (#577170) to post selected text to <a href="http://pastebin.com" rel="nofollow">pastebin.com</a>. This version uses the latest API. You'll want to change the following variables to your preferences: email, nick, expiry.</p>
Interactive Mandelbrot Fractal Using HTML5 Canvas (JavaScript)
2017-06-06T03:48:09-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/580804-interactive-mandelbrot-fractal-using-html5-canvas/
<p style="color: grey">
JavaScript
recipe 580804
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/canvas/">canvas</a>, <a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/math/">math</a>).
</p>
<p>Interactive Mandelbrot Fractal Using HTML5 Canvas.</p>
<p>(Download and save as html file and open it.)</p>
<p>(Tested only using Firefox browser.)</p>
Komodo JS macro: example chess match (JavaScript)
2012-10-24T16:59:51-07:00Todd Whitemanhttp://code.activestate.com/recipes/users/2666241/http://code.activestate.com/recipes/578304-komodo-js-macro-example-chess-match/
<p style="color: grey">
JavaScript
recipe 578304
by <a href="/recipes/users/2666241/">Todd Whiteman</a>
(<a href="/recipes/tags/chess/">chess</a>, <a href="/recipes/tags/editor/">editor</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>).
</p>
<p>This is an example macro that will play a specific chess game (Deep Blue v's Garry Kasparov) inside the Komodo editor.</p>
Sierpinski Triangle Fractal using HTML5 Canvas (JavaScript)
2010-07-07T15:07:30-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577294-sierpinski-triangle-fractal-using-html5-canvas/
<p style="color: grey">
JavaScript
recipe 577294
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>).
</p>
<p>Sierpinski Triangle Fractal using Line Automaton (1D CA).
The 1D CA rule used is actually Pascal's Triangle Mod 2.
Tested only using Firefox 3.5.</p>
slugify: make a string usable in a URL or filename (JavaScript)
2011-07-12T17:46:49-07:00Trent Mickhttp://code.activestate.com/recipes/users/4173505/http://code.activestate.com/recipes/577787-slugify-make-a-string-usable-in-a-url-or-filename/
<p style="color: grey">
JavaScript
recipe 577787
by <a href="/recipes/users/4173505/">Trent Mick</a>
(<a href="/recipes/tags/filename/">filename</a>, <a href="/recipes/tags/nodejs/">nodejs</a>, <a href="/recipes/tags/slug/">slug</a>, <a href="/recipes/tags/slugify/">slugify</a>, <a href="/recipes/tags/url/">url</a>).
Revision 2.
</p>
<p>"Slugify" a string so it has only alphanumeric and hyphen characters. Useful for URLs and filenames. This is a JavaScript (node.js too) version of <a href="http://code.activestate.com/recipes/577257/">Recipe 577257</a>.</p>
<p>Note: It is missing the guarantee that only ascii characters are passed through. I don't know an NFKD equivalent in JavaScript-land.</p>
node.js quicklog method to log to a file (JavaScript)
2010-08-11T05:08:57-07:00Trent Mickhttp://code.activestate.com/recipes/users/4173505/http://code.activestate.com/recipes/577351-nodejs-quicklog-method-to-log-to-a-file/
<p style="color: grey">
JavaScript
recipe 577351
by <a href="/recipes/users/4173505/">Trent Mick</a>
(<a href="/recipes/tags/logging/">logging</a>, <a href="/recipes/tags/nodejs/">nodejs</a>).
</p>
<p>I tend to have a "quicklog" method for a few of the languages I'm working in to do logging when stdout/stderr isn't necessarily available (GUI app) or convenient (lots of other output on stdout, etc.). My usage with <a href="http://nodejs.org">nodejs</a> was while working on the node REPL. Log output to stdout interfered with the REPL.</p>
JavaScript WebSocket client for Python + Go WebSocket-based system monitoring example (JavaScript)
2014-01-03T21:09:54-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/578806-javascript-websocket-client-for-python-go-websocke/
<p style="color: grey">
JavaScript
recipe 578806
by <a href="/recipes/users/4173351/">Vasudev Ram</a>
(<a href="/recipes/tags/golang/">golang</a>, <a href="/recipes/tags/javascript/">javascript</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/sysadmin/">sysadmin</a>, <a href="/recipes/tags/unix/">unix</a>, <a href="/recipes/tags/websockets/">websockets</a>, <a href="/recipes/tags/windows/">windows</a>).
</p>
<p>This recipe is the JavaScript client side of an overall recipe that shows how to do system monitoring using WebSockets, Python, Go (using websocketd), and JavaScript + HTML. The server side of the recipe (in Python, and using websocketd which is written in Go), is here:</p>
<p><a href="http://code.activestate.com/recipes/578803-using-websocketd-with-python-for-web-based-system-/?in=user-4173351" rel="nofollow">http://code.activestate.com/recipes/578803-using-websocketd-with-python-for-web-based-system-/?in=user-4173351</a></p>
<p>The system monitoring example shows the system disk space info (total, used and free) using the Python psutil module.</p>
Eight queen problem (Javascript) (JavaScript)
2013-03-20T19:03:44-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578497-eight-queen-problem-javascript/
<p style="color: grey">
JavaScript
recipe 578497
by <a href="/recipes/users/4174477/">Thomas Lehmann</a>
(<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/queen/">queen</a>, <a href="/recipes/tags/queens/">queens</a>).
</p>
<ul>
<li>Adding this for my old <a href="http://code.activestate.com/recipes/577438/">recipe 577438</a> (in Python).</li>
<li>Use node.js or HTML as execution (see comments in "log" function)</li>
</ul>
Komodo JS Macro - insert a relative path from the current editor file (JavaScript)
2012-02-24T00:23:09-08:00Todd Whitemanhttp://code.activestate.com/recipes/users/2666241/http://code.activestate.com/recipes/577306-komodo-js-macro-insert-a-relative-path-from-the-cu/
<p style="color: grey">
JavaScript
recipe 577306
by <a href="/recipes/users/2666241/">Todd Whiteman</a>
(<a href="/recipes/tags/javascript/">javascript</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/path/">path</a>, <a href="/recipes/tags/relative/">relative</a>).
Revision 3.
</p>
<p>A <a href="http://www.activestate.com/komodo">Komodo</a> JavaScript macro that can be used to generate a relative path from the current editor file location, which works great for HTML when linking to relative style sheets, images, etc...</p>
<p>Upon execution of this macro, you will be prompted to browse and select the target file, then upon selecting the target path, the relative path location will be inserted into the editor at the current position.</p>
<p>To best use this macro - assign a custom key-binding to the macro and then trigger the macro at will.</p>
Komodo Macro - Copy to clipboard code selection in HTML format (JavaScript)
2010-04-14T07:17:59-07:00Davide Ficanohttp://code.activestate.com/recipes/users/4166571/http://code.activestate.com/recipes/577193-komodo-macro-copy-to-clipboard-code-selection-in-h/
<p style="color: grey">
JavaScript
recipe 577193
by <a href="/recipes/users/4166571/">Davide Ficano</a>
(<a href="/recipes/tags/clipboard/">clipboard</a>, <a href="/recipes/tags/html/">html</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>).
</p>
<p>This macro makes easy to paste on documents (MS Office, Open Office, iWorks Pages) code snippets with syntax highlight and/or line numbers.</p>
<p>This macro copies the selected code text or whole document if no selection is present on clipboard in HTML format.</p>
<p>On OSX you need at least Komodo 6 because previous versions don't support data flavors</p>
Novel JavaScript Text Compressor (JavaScript)
2011-01-31T15:41:36-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577557-novel-javascript-text-compressor/
<p style="color: grey">
JavaScript
recipe 577557
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/compression/">compression</a>, <a href="/recipes/tags/encode/">encode</a>, <a href="/recipes/tags/encryption/">encryption</a>).
</p>
<p>Compression, encryption, and data codecs are all related fields that most programmers will use ready-made solutions for. This recipe is a shallow adventure into the writing of original code and algorithms that explores a combination of those topics. Based on the work of <a href="http://code.activestate.com/recipes/577433/">recipe 577433</a>, the code here is compliant with JavaScript and will run a test of itself when executed. From the program's report, one can gather that the novel procedures compress the source and accurately decompress it again. For those who wish to experiment further with the concept, note that fewer unique characters will yield higher compression ratios.</p>
<p>To get a copy of <em>biginteger.js</em> for the program to run and compression algorithm to operator, please go to <a href="http://silentmatt.com/biginteger/" rel="nofollow">http://silentmatt.com/biginteger/</a> and use the latest version of Matthew Crumley's excellent JavaScript big integer library.</p>
Komodo JS Macro: Execute JavaScript (JavaScript)
2012-05-07T13:21:30-07:00Patrick Clokehttp://code.activestate.com/recipes/users/4180275/http://code.activestate.com/recipes/578120-komodo-js-macro-execute-javascript/
<p style="color: grey">
JavaScript
recipe 578120
by <a href="/recipes/users/4180275/">Patrick Cloke</a>
(<a href="/recipes/tags/debug/">debug</a>, <a href="/recipes/tags/debugging/">debugging</a>, <a href="/recipes/tags/editor/">editor</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>).
</p>
<p>Executes a JavaScript file (or the selected text) and display the results in the command output window.</p>
Javascript Namespaces (JavaScript)
2009-07-12T07:21:40-07:00Mike Kosshttp://code.activestate.com/recipes/users/4171086/http://code.activestate.com/recipes/576839-javascript-namespaces/
<p style="color: grey">
JavaScript
recipe 576839
by <a href="/recipes/users/4171086/">Mike Koss</a>
(<a href="/recipes/tags/javascript/">javascript</a>, <a href="/recipes/tags/namespaces/">namespaces</a>).
Revision 2.
</p>
<p>This recipe enables you to modularize javascript libraries by placing all library code within a namespace object. All namespaces are rooted at "window.global_namespace". References between namespaces are supported by the Import function, which allows forward references to namespaces that have yet to be defined.</p>
<p>See code comment for more detailed examples.</p>
Komodo JS Macro - show custom code completions (JavaScript)
2010-01-18T13:28:16-08:00Todd Whitemanhttp://code.activestate.com/recipes/users/2666241/http://code.activestate.com/recipes/577012-komodo-js-macro-show-custom-code-completions/
<p style="color: grey">
JavaScript
recipe 577012
by <a href="/recipes/users/2666241/">Todd Whiteman</a>
(<a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/codeintel/">codeintel</a>, <a href="/recipes/tags/completions/">completions</a>, <a href="/recipes/tags/javascript/">javascript</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/scintilla/">scintilla</a>, <a href="/recipes/tags/toddw/">toddw</a>).
</p>
<p>A <a href="http://www.activestate.com/komodo">Komodo</a> JavaScript macro that can be used to display a custom completion pop-up.</p>
<p><img src="http://community.activestate.com/files/images/custom_completions.png" alt="Completions image" /></p>
Komodo JS Macro -- Escape HTML Special Characters in current file (JavaScript)
2012-05-25T20:04:49-07:00Keegan Brownhttp://code.activestate.com/recipes/users/4182206/http://code.activestate.com/recipes/578146-komodo-js-macro-escape-html-special-characters-in-/
<p style="color: grey">
JavaScript
recipe 578146
by <a href="/recipes/users/4182206/">Keegan Brown</a>
(<a href="/recipes/tags/characters/">characters</a>, <a href="/recipes/tags/html/">html</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/special/">special</a>, <a href="/recipes/tags/xhtml/">xhtml</a>).
</p>
<p>Escapes all Special Characters to their HTML Special Character equivalent.</p>
Macro to Quick find (ctrl+f3) on double click (JavaScript)
2011-07-22T07:46:26-07:00Adamhttp://code.activestate.com/recipes/users/4173315/http://code.activestate.com/recipes/577801-macro-to-quick-find-ctrlf3-on-double-click/
<p style="color: grey">
JavaScript
recipe 577801
by <a href="/recipes/users/4173315/">Adam</a>
(<a href="/recipes/tags/editor/">editor</a>, <a href="/recipes/tags/javascript/">javascript</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/scintilla/">scintilla</a>).
Revision 3.
</p>
<p>This does a search for the selected word when you double click it. Functionality similar to Notepad++. Faster that ctrl-f3.</p>