JSFiddle

  • Detect Markdown section boundaries

    No-Library (pure JS), HTML, CSS, JavaScript

    s = "aaa\nbbb\n\n- \n\n-- \nddd\n--- \neee\n---\n-----\n----- \n"+(Array(38).join(" "))+"***\n"+(Array(38 ...
  • Detect image mimetype by first bits #5 is the latest revision

    first bits in base64: R0lGOD - gif iVBORw - png /9j/4 - jpeg UklGR - webp AAABAA - ico JVBERi0xLj - pdf UEsDBBQAAAAIA - zip UEsDBBQABgAIAAAAIQ - xlsx

    var base64toDataURL = function (data) {
        return data.replace(/^R0lGOD/, 'data:image/gif;base64,R0lGOD')
            .replace(/^iVBORw/, 'data:image/png;base64,iVBORw ...
  • webp alternative

    No-Library (pure JS), HTML, CSS, JavaScript

    var nowebp = function (i, ext) {
        var r = /webp$/,
            attr = i.src ? 'src' : 'poster',
            attrValue = i.getAttribute(attr);
    
        if (r.test ...
  • Math.sum()

    No-Library (pure JS), HTML, CSS, JavaScript

    Math.sum = function(a,b){
        var c = d = "";
        if(typeof a === 'string'){
            if(typeof b === 'string'){
                e = a.length;
                for ...
  • Invisible, self-replacing script

    No-Library (pure JS), HTML, CSS, JavaScript

    javascript:(function(){var s = document.createElement('script'); s.id='s1';s.innerText = '(function(a,b){a.parentNode.replaceChild(b, a ...
  • Telephone input

    No-Library (pure JS), HTML, CSS, JavaScript

    document.querySelector('[type="tel"]').onkeypress = function(){
        this.setAttribute('value',this.value=this.value
            .replace(/(^\d)/,'+371-$1')
            .replace(/(^\+\d{3 ...
  • fibonacci #3 is the latest revision

    No-Library (pure JS), HTML, CSS, CoffeeScript

    A000045=[0,1] # sequence A000045 in OEIS
    f=(x)->(if x<2 then x else A000045[x]||A000045[x]=((x)->f(x-1)+f(x-2))(x))
    console.log f(_i ...</2>
  • font-weight

    No-Library (pure JS), HTML, CSS, JavaScript

    arr = document.getElementsByName('fontWeight');
    for(x in arr){
      arr[x].onchange = function(){
        for(y in arr){
    
    isNaN(y*1) || (this ...
  • Hover hack; nth-child

    No-Library (pure JS), HTML, CSS, JavaScript

    <ul class="list">
        <li><a href="#1">1</a></li>
        <li><a href="#2">2</a></li>
        <li><a href="#3">3</a></li>
        <li><a href="#4">4</a></li>
        <li><a href="#5">5</a></li>
        <li><a href="#6">6</a></li>
    </ul>    
  • Text input`s default value in placeholder

    No-Library (pure JS), HTML, CSS, JavaScript

    'use strict';
    [].forEach.call(document.querySelectorAll('input'),function(e){
        e.onclick = function(){
            this.value || (this.value = this.getAttribute('placeholder'));
            this ...