Skip to content

Instantly share code, notes, and snippets.

@jaapie
jaapie / number-format-ensurinator.js
Last active Aug 29, 2015
Allows only number keys, enter and full stop to be entered into an input[type=number] and ensures the format is that of a floating point number
View number-format-ensurinator.js
(function() {
"use strict";
var els = document.querySelectorAll('input[type=number]');
function makeKeypressEventHandler() {
return function (e) {
var keyCode = e.which || e.keyCode;
if ((keyCode >= 48 && keyCode <= 57) ||
keyCode == 13 || keyCode == 46) {
@jaapie
jaapie / up.sh
Last active Dec 14, 2015
A shell function for Bash that goes up a specified number of directory levels. Easier than typing `cd ../../../` etc.
View up.sh
#! /bin/bash
function up () {
levels=$1
if [ -z "$levels" ]; then
levels=1
fi
# Test if $levels is a number; the -eq operator expects a number, and will
@jaapie
jaapie / rwd.css
Last active Dec 14, 2015 — forked from trey/rwd.css
My version of twitter-bootstrap-compatible responsive breakpoints. I couldn't get them to work properly, so I fiddled around with them until I came up with the code below.
View rwd.css
/* http://twitter.github.com/bootstrap/scaffolding.html#responsive */
/* Landscape phones and down */
@media (max-width: 480px) {
}
/* Landscape phone to portrait tablet */
@media (max-width: 767px) and (min-width: 481px) {
}