Input text selection Original code of Mihai Bazon, 2006 http://www.bazon.net/mishoo/
965823
function setSelectionRange(input, start, end){
    if (arguments.length < 3)
      end = start;

    if (input.setSelectionRange)
      input.setSelectionRange(start, end);
    else
      if (input.createTextRange)
      {
        // IE
        var range = input.createTextRange();
        range.collapse(true);
        range.moveStart('character', start);
        range.moveEnd('character', end - start);
        range.select();
      }
  }
723852
function createCodeReader(text) {
		var index = 0,
			line = 1,
			column = 1,
			length,
			EOF = undefined,
			currentChar,
			nextReadBeginsLine;

		text = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n"); //normalize line endings to unix

		length = text.length;
		currentChar = length > 0 ? text.charAt(0) : EOF;

		function getCharacters(count) {
			var value;
			if (count === 0) {
				return "";
			}

			count = count || 1;

			value = text.substring(index + 1, index + count + 1);
			return value === "" ? EOF : value;
		}

		return {
			toString: function() {
				return "length: " + length + ", index: " + index + ", line: " + line + ", column: " + column + ", current: [" + currentChar + "]";
			},

			peek: function(count) {
				return getCharacters(count);
			},

			substring: function() {
				return text.substring(index);
			},

			peekSubstring: function() {
				return text.substring(index + 1);
			},

			read: function(count) {
				var value = getCharacters(count),
					newlineCount,
					lastChar;

				if (value === "") {
					//this is a result of reading/peeking/doing nothing
					return value;
				}

				if (value !== EOF) {
					//advance index
					index += value.length;
					column += value.length;

					//update line count
					if (nextReadBeginsLine) {
						line++;
						column = 1;
						nextReadBeginsLine = false;
					}

					newlineCount = value.substring(0, value.length - 1).replace(/[^\n]/g, "").length;
					if (newlineCount > 0) {
						line += newlineCount;
						column = 1;
					}

					lastChar = last(value);
					if (lastChar === "\n") {
						nextReadBeginsLine = true;
					}

					currentChar = lastChar;
				} else {
					index = length;
					currentChar = EOF;
				}

				return value;
			},

			text: function() { return text; },

			getLine: function() { return line; },
			getColumn: function() { return column; },
			isEof: function() { return index >= length; },
			isSol: function() { return column === 1; },
			isSolWs: function() {
				var temp = index,
					c;
				if (column === 1) {
					return true;
				}

				//look backward until we find a newline or a non-whitespace character
				while ((c = text.charAt(--temp)) !== "") {
					if (c === "\n") {
						return true;
					}
					if (!/\s/.test(c)) {
						return false;
					}
				}

				return true;
			},
			isEol: function() { return nextReadBeginsLine; },
			EOF: EOF,
			current: function() { return currentChar; }
		};
	}
1146262
function demo() {
  // Translate phrase
  w(__('Hello!'));
  // Comment for translator
  w(__('Hello!# This is comment.'));
  // Phrase with id 
  w(__('Hello!#another_hello'));
  // Phrase with id and comment
  w(__('Hello!#another_hello2 Please translate this another way.'));
  // Phrase with # but not comment
  w(__('There is ## in this phrase but it is not comment.'));
  // This phrase will not be translated - missing in translation.
  w(__('Hello?'));
  // Escapes for placeholders
  w(__('This is %% percent symbol.'));
  // Placeholders with additional arguments
  w(__('My %(0)s is faster then your %(1)s!', 'SSD', 'HDD'));
  // Placeholders with array
  w(__('My %(0)s is faster then your %(1)s!', [ 'Kawasaki', 'Segway' ]));
  // Placeholders with object
  w(__('My %(0)s is faster then your %(1)s!', { 0: 'Core i7', 1: '486DX' }));
  // Both names and order
  w(__('Let\'s count in English: %s, %s, %(3)s and %s.', 'one', 'two', 'four', 'three'));
  // Plural forms
  w(__(['Inbox: %n unreaded message.', 'Inbox: %n unreaded messages.'], 1));
  w(__(['Inbox: %n unreaded message.', 'Inbox: %n unreaded messages.'], 12));
  w(__(['Inbox: %n unreaded message.', 'Inbox: %n unreaded messages.'], 22));
  // All-in-one
  w(__([
    '%n developer from our team uses %(0)s with %(1)s.# Comment 1',
    '%n developers from our team uses %(0)s with %(1)s.# Comment 2'
    ], 1, 'C', 'vim'
  ));
  w(__([
    '%n developer from our team uses %(0)s with %(1)s.# Comment 3',
    '%n developers from our team uses %(0)s with %(1)s.# Comment 4'
    ], 3, [ 'Python', 'PyCharm' ]
  ));
  w(__([
    '%n developer from our team uses %(0)s with %(1)s.# Multiline\ncomment',
    '%n developers from our team uses %(0)s with %(1)s.# Another\nmultiline\ncomment'
    ], 7, { 0: 'Node.js', 1: 'Sublime Text 2' }
  ));
  // No args - empty string
  w(__());
}
134585
function base32DecodeLastCharacter(chunk, characterIndex, buffer, index) {
    const byteIndex = Math.floor(index + (characterIndex * 5) / 8);
    const offset = characterIndex % 8;
    switch (offset) {
        case 1:
            buffer[byteIndex] |= chunk >>> 2;
            break;
        case 3:
            buffer[byteIndex] |= chunk >>> 4;
            break;
        case 4:
            buffer[byteIndex] |= chunk >>> 1;
            break;
        case 6:
            buffer[byteIndex] |= chunk >>> 3;
            break;
        case 7:
            buffer[byteIndex] |= chunk;
            break;
    }
}
339622
function(e) {
      if (e.keyCode != 13) return;
      if (!this.input.val()) return;

      Todos.create({title: this.input.val()});
      this.input.val('');
    }
293399
function(codeUrl, callback) {
	   var url = ("http://javascript.neyric.com/yql/js.php?url="+window.encodeURIComponent(codeUrl)).replace(new RegExp("'","g"),"\\'");
		var yql = "use '"+url+"' as yqlexconsole; select * from yqlexconsole;";
		inputEx.YQL.query(yql,callback);
	}
99676
function translate_code(PHP_ParserGenerator_Rule $rp)
    {
        $lhsused = 0;    /* True if the LHS element has been used */
        $used = array();   /* True for each RHS element which is used */
        
        $this->append_str('', 0);
        for ($i = 0; $i < strlen($rp->code); $i++) {
            $cp = $rp->code[$i];
            if (preg_match('/[A-Za-z]/', $cp) &&
                 ($i === 0 || (!preg_match('/[A-Za-z0-9_]/', $rp->code[$i - 1])))) {
                //*xp = 0;
                // previous line is in essence a temporary substr, so
                // we will simulate it
                $test = substr($rp->code, $i);
                preg_match('/[A-Za-z0-9_]+/', $test, $matches);
                $tempcp = $matches[0];
                $j = strlen($tempcp) + $i;
                if ($rp->lhsalias && $tempcp == $rp->lhsalias) {
                    $this->append_str("\$this->_retvalue", 0);
                    $cp = $rp->code[$j];
                    $i = $j;
                    $lhsused = 1;
                } else {
                    for ($ii = 0; $ii < $rp->nrhs; $ii++) {
                        if ($rp->rhsalias[$ii] && $tempcp == $rp->rhsalias[$ii]) {
                            if ($rp->code[0] == '@') {
                                /* If the argument is of the form @X then substitute
                                ** the token number of X, not the value of X */
                                $this->append_str("\$this->yystack[\$this->yyidx + " .
                                    ($ii - $rp->nrhs + 1) . "]->major", -1);
                            } else {
                                $sp = $rp->rhs[$ii];
                                if ($sp->type == PHP_ParserGenerator_Symbol::MULTITERMINAL) {
                                    $dtnum = $sp->subsym[0]->dtnum;
                                } else {
                                    $dtnum = $sp->dtnum;
                                }
                                $this->append_str("\$this->yystack[\$this->yyidx + " .
                                    ($ii - $rp->nrhs + 1) . "]->minor", 0);
                            }
                            $cp = $rp->code[$j];
                            $i = $j;
                            $used[$ii] = 1;
                            break;
                        }
                    }
                }
            }
            $this->append_str($cp, 1);
        } /* End loop */
        
        /* Check to make sure the LHS has been used */
        if ($rp->lhsalias && !$lhsused) {
            PHP_ParserGenerator::ErrorMsg($this->filename, $rp->ruleline,
                "Label \"%s\" for \"%s(%s)\" is never used.",
                $rp->lhsalias, $rp->lhs->name, $rp->lhsalias);
                $this->errorcnt++;
        }
        
        /* Generate destructor code for RHS symbols which are not used in the
        ** reduce code */
        for($i = 0; $i < $rp->nrhs; $i++) {
            if ($rp->rhsalias[$i] && !isset($used[$i])) {
                PHP_ParserGenerator::ErrorMsg($this->filename, $rp->ruleline,
                    "Label %s for \"%s(%s)\" is never used.",
                    $rp->rhsalias[$i], $rp->rhs[$i]->name, $rp->rhsalias[$i]);
                $this->errorcnt++;
            } elseif ($rp->rhsalias[$i] == 0) {
                if ($rp->rhs[$i]->type == PHP_ParserGenerator_Symbol::TERMINAL) {
                    $hasdestructor = $this->tokendest != 0;
                }else{
                    $hasdestructor = $this->vardest !== 0 || $rp->rhs[$i]->destructor !== 0;
                }
                if ($hasdestructor) {
                    $this->append_str("  \$this->yy_destructor(" .
                        ($rp->rhs[$i]->index) . ", \$this->yystack[\$this->yyidx + " .
                        ($i - $rp->nrhs + 1) . "]->minor);\n", 0);
                } else {
                    /* No destructor defined for this term */
                }
            }
        }
        $cp = $this->append_str('', 0);
        $rp->code = $cp;
    }
820192
protected function drawBackOfficeInputOperators($inputKey)
    {
        $html = '';

        $inputs = $this->getValidators();

        if (isset($inputs['inputs'][$inputKey])) {
            $html = $this->facade->getParser()->render(
                'coupon/condition-fragments/condition-selector.html',
                [
                    'operators' => $inputs['inputs'][$inputKey]['availableOperators'],
                    'value'     => isset($this->operators[$inputKey]) ? $this->operators[$inputKey] : '',
                    'inputKey'  => $inputKey
                ]
            );
        }

        return $html;
    }
728125
function(input) {

			// Nos deshacemos del caracter final `:` para su validación

			var size = (input = _toString(input)).length;

			input = (input.substr(size-1, 1) === ':') ? input.substr(0, input.length-1) : input;

			// Si el protocolo es correcto añadimos `:` al final del mismo
			// si no lo es devolvemos una cadena vacía

			return Public.normalize.regex_rfc3986_schema.test((input = input.toLowerCase())) ? (input + ':') : '';

		}
842273
def selection_text=(str)
      from = [@text_input.selection_start, @text_input.caret_pos].min
      to = [@text_input.selection_start, @text_input.caret_pos].max
      new_length = str.length

      full_text = text
      tags_length_before = (0...from).inject(0) {|m, i| m + @tags[i].length }
      tags_length_inside = (from...to).inject(0) {|m, i| m + @tags[i].length }
      range = (selection_range.first + tags_length_before)...(selection_range.last + tags_length_before + tags_length_inside)
      full_text[range] = str.encode('UTF-8', undef: :replace)
      @text_input.text = full_text

      @text_input.selection_start = @text_input.caret_pos = from + new_length

      recalc # This may roll back the text if it is too long!

      publish :changed, self.text

      str
    end
272703
def standard_input():
    """"""
    with click.get_text_stream("stdin") as stdin:
        while stdin.readable():
            line = stdin.readline()
            if line:
                yield line.strip().encode("utf-8")
959773
public static function charsetDecode($input,$_input_charset ,$_output_charset) {
        $output = "";
        if(!isset($_input_charset) )$_input_charset  = $_input_charset ;
        if($_input_charset == $_output_charset || $input ==null ) {
            $output = $input;
        } elseif (function_exists("mb_convert_encoding")) {
            $output = mb_convert_encoding($input,$_output_charset,$_input_charset);
        } elseif(function_exists("iconv")) {
            $output = iconv($_input_charset,$_output_charset,$input);
        } else die("sorry, you have no libs support for charset changes.");
        return $output;
    }
669701
function makeInputText(type, classes, placeholder, defaultValue, func, useCapture, listners) {
  let workClasses = [];
  if (classes !== null) {
    workClasses = workClasses.concat(classes);
  }

  let ele = null;
  if (type === "text") {
    workClasses.push("input-text");
    ele = createElementWithClass("input", workClasses);
  } else if (type === "search") {
    workClasses.push("input-search");
    ele = createElementWithClass("input", workClasses);
  } else if (type === "textarea") {
    workClasses.push("input-textarea");
    ele = createElementWithClass("textparea", workClasses);
  } else {
    return null;
  }
  ele.type = type;
  if (placeholder !== null) {
    ele.placeholder = placeholder;
  }
  if (defaultValue !== null) {
    ele.defaultValue = defaultValue;
  }

  if (!isEmptyObject(func)) {
    listners.push(setEventListener(ele, "input", func, useCapture));
  }
  return ele;
}
195086
function( popup, modify_a_href )
        {
            var textbox = document.createElement('input');
            textbox.placeholder = 'www.example.com';
            if( modify_a_href )
                textbox.value = modify_a_href.href;
            textbox.style.width = '20em';
            textbox.style.maxWidth = parseInt(node_container.offsetWidth *2/3) + 'px';
            textbox.autofocus = true;
            if( modify_a_href )
                addEvent( textbox, 'input', function( e )
                {
                    var url = textbox.value.trim();
                    if( url )
                        modify_a_href.href = url;
                });
            addEvent( textbox, 'keypress', function( e )
            {
                var key = e.which || e.keyCode;
                if( key != 13 )
                    return;
                var url = textbox.value.trim();
                if( modify_a_href )
                    ;
                else if( url )
                {
                    var url_scheme = url;
                    if( ! /^[a-z0-9]+:\/\//.test(url) )
                        url_scheme = "http://" + url;
                    if( commands.getSelectedHTML() )
                        commands.insertLink( url_scheme );
                    else
                    {
                        // Encode html entities - http://stackoverflow.com/questions/5499078/fastest-method-to-escape-html-tags-as-html-entities
                        var htmlencode = function( text ) {
                            return text.replace(/[&<>"]/g, function(tag)
                            {
                                var charsToReplace = { '&':'&amp;', '<':'&lt;', '>':'&gt;', '"':'&quot;' };
                                return charsToReplace[tag] || tag;
                            });
                        }
                        commands.insertHTML( '<a href="' + htmlencode(url_scheme) + '">' + htmlencode(url) + '</a>' );
                    }
                }
                commands.closePopup().collapseSelection();
                node_contenteditable.focus();
            });
            popup.appendChild( textbox );
            // set focus
            window.setTimeout( function()
            {
                textbox.focus();
                add_class_focus();
            }, 1 );
        }
183012
function( input ) {

    var self = this

    return input.replace(
      /[=][?]([^?]+)[?]([a-z])[?]([^?]*)[?][=]/gi,
      function( match, charset, type, data ) {

        type = type.toUpperCase()

        return type === 'B' ?
          self.decodeBase64( data, charset ) :
          self.decodeQP( data, charset, true )

      }
    )

  }
219537
def code(self, text, lang=None):
        """"""
        # WARNING: lang is discarded currently.
        with self.paragraph(stylename='code'):
            lines = text.splitlines()
            for line in lines[:-1]:
                self._code_line(line)
                self.linebreak()
            self._code_line(lines[-1])
1029648
function(element) {
    if('TEXTAREA'===element.nodeName || 'SELECT'===element.nodeName
      || ('INPUT'===element.nodeName&&element.hasAttribute('type')
        &&('text'===element.getAttribute('type')
          || 'number'===element.getAttribute('type')
          || 'password'===element.getAttribute('type')
          || 'file'===element.getAttribute('type')
          || 'date'===element.getAttribute('type'))
      )
    ) {
      return true;
    }
    return false;
  }