Skip to content

Instantly share code, notes, and snippets.

@ludder
ludder / classList.js
Created December 6, 2012 17:28
Backwards compatible classList functions
/**
* Check element has a certain classname
* We cannot use classList yet because of browser support
* @param {Object} ele DOM element
* @param {String} cls Classname
* @return {Boolean} True is classname is found
*/
function hasClass(ele,cls) {
if (ele === null || cls === '') return false;
return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
@ludder
ludder / pre-commit
Created February 13, 2015 14:50
Update package.json version number on git commit
#!/bin/sh
#
npm version patch
git add package.json
exit 0
@ludder
ludder / grunt-git-hooks
Created May 20, 2014 07:45
Copy git hooks to hooks folder with Grunt
grunt.registerTask('default', function () {
var fs = require('fs');
// my precommit hook is inside the repo as /hooks/pre-commit
// copy the hook file to the correct place in the .git directory
grunt.file.copy('hooks/pre-commit', '.git/hooks/pre-commit');
// chmod the file to readable and executable by all
fs.chmodSync('.git/hooks/pre-commit', '755');
});