Skip to content

Instantly share code, notes, and snippets.

Avatar

Nico Haemhouts nicohaemhouts

View GitHub Profile
View Archiving a remote branch
git tag archive/<your-branch> <your-branch>
git push --tags
git push -d origin <your-branch>
git branch -D <your-branch>
@nicohaemhouts
nicohaemhouts / Limit-the-number-of-lines-in-a-textarea.markdown
Last active Dec 14, 2016
Limit the number of lines in a textarea
View Limit-the-number-of-lines-in-a-textarea.markdown

Limit the number of lines in a textarea

This limits the number of lines of any textarea that has the attribute 'data-limit-rows' set to 'true'. The limit is the 'rows'-attribute of the textarea.

To know how many lines have been entered you have to look at the number of newline characters (\n) in the text. You could do this by splitting text on the newline character, and looking at the length of the resulting array: i.e. myText.split(/\n/g).length; This would work fine in every browser, except for one special case in Internet Explorer 8, whereby the user hits the enter key several times in a row, thus producing empty lines. In this case Internet Explorer 8 excludes all empty values from the resulting array, ie those places where the delimiters appear next to each other. The result is that the usr can enter more lines of text than permitted. This is probably also true for Internet Explorer versions lower than 8, but I didn't check.

To know which key was pressed it's b

@nicohaemhouts
nicohaemhouts / _.md
Last active Aug 29, 2015
Random Increasing Line Chart
View _.md
@nicohaemhouts
nicohaemhouts / _.md
Last active Aug 29, 2015
Updating Area Chart
View _.md
@nicohaemhouts
nicohaemhouts / _.md
Last active Aug 29, 2015
Scrolling line chart
View _.md
@nicohaemhouts
nicohaemhouts / _.md
Last active Aug 29, 2015
Force Layout NGS 2
View _.md
@nicohaemhouts
nicohaemhouts / _.md
Last active Aug 29, 2015
Force Layout NGS
View _.md
View _.md
@nicohaemhouts
nicohaemhouts / _.md
Last active Aug 29, 2015
Force Layout with Radial Progress
View _.md
@nicohaemhouts
nicohaemhouts / _.md
Last active Aug 29, 2015
CDS EventsPerSecond
View _.md