JSFiddle

  • React Base Fiddle (JSX, latest)

    Starting point for creating JSFiddles with React. This uses React with Addons and the latest build from the master branch)

    var Hello = React.createClass({
        render: function() {
            return <div>Hello {this.props.name}</div>;
        }
    });
     
    React.render(<Hello name="World" />, document.body);
    
    
  • React Simple Dropdown #286 is the latest revision

    A simple dropdown (select) component written in React using JSX. Takes and array of value/label pairs and displays a select. Optionally takes an 'onchange' function as a param. This will be called with details of the old and newly selected values.

    var Dropdown = React.createClass({
    
        propTypes: {
            id: React.PropTypes.string.isRequired,
            options: React.PropTypes.array.isRequired,
            value: React.PropTypes.oneOfType(
                [
                    React ...
  • Ordered list (OL) without the indent

    Simple CSS to display an ordered list in which the list items have no indentation.

    <span>This is text.</span>
    
    <ol>
       <li>a<br>Second line.</li>
       <li>b</li>
       <li>c</li>
    </ol>
    
    <span>This is also text.</span>
    
  • Increment the numeric part of a string

    When you have a string that ends with a number, this simple regular expression will allow you to increment the number part e.g. take a text field containing "abc15" and increment it by 1 to return "abc16". Similarly, "xyz99" will become "xyz100", etc.

    function incrementString(str) {
        
        return str.replace(/\d+$/, function(n) { return ++n });
    
    }
    
    var o = document.getElementById('output');
    
    
    // The following show the ...
  • hapi-swagger 'startswith' bug fix #15 is the latest revision

    Illustration of a bug fix for hapi-swagger that ensures all relevant routes, and only relevant routes, are sent to Swagger.

    var o = document.getElementById('output');
    
    var toFind = "movies";
    var re = '^/' + toFind + '(/|$)';
    
    var routes = ['/movies','/movies/','/movies/{id}','/movies/{id}/','/movies ...
  • isValidObjectID #5 is the latest revision

    A simple function that uses a regular expression to validate that a string is a valid MongoDB object id (i.e. a 24 character hex string). More about MongoDB object id format here: http://docs.mongodb.org/manual/reference/object-id/

    function isValidObjectID(str) {
        
        // A valid Object Id must be 24 hex characters
        return (/^[0-9a-fA-F]{24}$/).test(str);
    
    }
    
    var o = document ...
  • jList: listGetAt

    Examples of the listGetAt function from the jList library.

    // listGetAt: Gets a list element at a specified position.
    
    
    var o = document.getElementById('output');
    
    
    o.innerHTML += '1. ' + jList.listGetAt('elem1 ...
  • jList: listGetAt

    Examples of the listGetAt function from the jList library.

    // listGetAt: Gets a list element at a specified position.
    
    
    var o = document.getElementById('output');
    
    
    o.innerHTML += '1. ' + jList.listGetAt('elem1 ...
  • jList: listUnion

    Examples of the listUnion function from the jList library.

    // listUnion: Combines the elements from two different lists.
    
    
    var o = document.getElementById('output');
    
    
    o.innerHTML += '1. ' + jList.listUnion('elem1,elem2 ...
  • jList: listReplaceNoCase

    Examples of the listReplaceNoCase function from the jList library.

    // listReplaceNoCase: Replaces any occurances of an element in a list with a different element. Matching is not case-sensitive.
    
    
    var o ...