|
|
Issue #34 (lastIndexOf(), Text Editors, Testing, Content)03/13/14
You most certainly know about JavaScript's indexOf() method, which searches a given string for the first instance of a given substring, returning the position of the start of the substring. If the substring is not found, it returns -1.
There's also a method called lastIndexOf(), which you don't see as often. This method returns the position of the last instance of the substring, also returning -1 if nothing is found. And just like indexOf(), lastIndexOf() lets you pass in an optional second argument that defines where in the string to start the search.
var stringOne = "How much wood could " +
"a wood chuck chuck if " +
"a wood chuck could chuck wood?",
findCandy = stringOne.lastIndexOf('wood'),
findCandy2 = stringOne.lastIndexOf('wood chuck'),
op = document.getElementById('op');
console.log(findCandy + ', ' + findCandy2); // "67 & 44"
|
The difference, however, with lastIndexOf() when using the optional parameter is the fact that the position is counted from the start, but the search goes in reverse from the defined position: So with the same string from the previous example, the following would return 22:
findCandy3 = stringOne.lastIndexOf('wood chuck', 32); // 22
|
This is because everything after character 32 is disregarded, because the search starts at character 32 and works backwards, looking for the substring "wood chuck". Here's the code.
As a side point, keep in mind that both these methods are case sensitive, so changing the substring to "Wood chuck" would return -1 in all cases.
Super easy stuff this week, huh? :)
Now on to this week's tools!
Text Editors, IDEs, etc.
Codeanywhere
"A code editor in a browser with an integrated ftp client, and all popular web formats are supported (HTML, PHP, JavaScript, CSS, and XML)."
Intel® XDK
"If you can write code in HTML5, CSS3 and JavaScript*, you can use the Intel® XDK to build an HTML5 web app or a hybrid app for all of the major app stores."
Colour Schemes
"I'd like to share with you a number of themes for some popular text editors that will hopefully be pleasing to your eyes and allow you to enjoy the time you spend in front of the screen."
ES6 Fiddle
A JavaScript playground with some options to work with some of the new ES6 features.
TMTheme Editor
This looks really nice... "A color scheme editor for SublimeText, Textmate and bunch of other text editors."
SublimeLinter
"A plugin for Sublime Text 3 that provides a framework for linting code. Whatever language you code in, SublimeLinter can help you write cleaner, better, more bug-free code."
cssPad
"A live HTML/CSS editor for rapid style protyping." This one actually has a CSS-y feel to its design. I don't know why.
Spacegray
"A set of custom UI themes for Sublime Text 2/3. It's all about hype and minimal. Comes in different flavors with accompanying Base16 color schemes." The "Spacegray Eighties" theme looks real nice.
Gist
"A Sublime Text 2 plugin for creating and editing Gists."
Testing and Debugging Tools
What's My Browser?
Grabs a snapshot of your browser details so you can send a link with the info to a support team.
Rollbar
"Real-time Error Tracking for Ruby, Python, PHP, Node.js, JavaScript, and Flash."
feedthebot
Not an official Google app, but a simple website that lets you enter a URL and it will assess the page based on Google Webmaster Guidelines.
Spof
"Uses a Blackhole server ... to simulate what will happen if a third-party provider goes down."
access_lint
"Run web accessibility audits on urls or files, from the command line or within Ruby."
Webmon
A highly configurable website monitoring service with the ability to do tests on API health and uptime.
Switcheroo Redirector
A Chrome extension that's "great for switching in development scripts for live scripts or switching between minified and development versions of frameworks such as jQuery, mootools etc."
Ezoic
This is really interesting: It's a "Website Improvement Platform" that will adjust your website's layout according to user interaction, to improve ad revenue.
WhatFont
A Chrome Extension to let you identify any font on a web page with a single click. I like this because I often find dev tools are annoying for this.
Documents, Files, Content, etc.
track-phone
"Use your mobile as a trackpad/keyboard for your media server or laptop during a presentation."
Casual
A fake data generator for JavaScript.
Dakait
"SFTP download and file organization tool for headless servers. Runs on Mac OS X and Linux."
HTML2PDF Web Service
"Design your invoices or reports in HTML, style them with CSS and convert the resulting page into a PDF document."
ZeroKnowledgeDocuments
"A client-side browser based application that allows the user to read and write encrypted text files to a cloud service."
A Tweet for Thought
Jared Spool quoting Luke Wroblewski on PayPal's mind-blowing mobile revenue increase over the past 5 years.
Suggestions / Corrections
Made something? Send links via Twitter @WebToolsWeekly (details here). No tutorials or articles, please. If you have any suggestions, corrections, or improvements, feel free to reply to this email.
Before I Go...
If you produce HTML email, you might want to start keeping tabs on the W3C's HTML for email Community Group.
Thanks to all for subscribing and reading!
Keep tooling,
Louis
webtoolsweekly.com
@WebToolsWeekly
|
|
|
|
|
|