The popular open-source contract for web designers and developers by Stuff & Nonsense
- Originally published: 23/12/2008
- Revised date: 15/12/2013
- Original post
| function slugify(text) | |
| { | |
| return text.toString().toLowerCase() | |
| .replace(/\s+/g, '-') // Replace spaces with - | |
| .replace(/[^\w\-]+/g, '') // Remove all non-word chars | |
| .replace(/\-\-+/g, '-') // Replace multiple - with single - | |
| .replace(/^-+/, '') // Trim - from start of text | |
| .replace(/-+$/, ''); // Trim - from end of text | |
| } |
| = IMAGEMAGICK | |
| Working with images, PDFs and the command line | |
| # convert from one format to another | |
| convert image.gif image.jpg | |
| # convert specific PDF page to image |
| $ npm install --save-dev connect-modrewrite | |
| Then edit gulp/server.js | |
| var modRewrite = require('connect-modrewrite'); | |
| function browserSyncInit(baseDir, files, browser) { | |
| browser = browser === undefined ? 'default' : browser; | |
| browserSync.instance = browserSync.init(files, { | |
| startPath: '/index.html', |
| * { | |
| -webkit-touch-callout:none; /* prevent callout to copy image, etc when tap to hold */ | |
| -webkit-text-size-adjust:none; /* prevent webkit from resizing text to fit */ | |
| -webkit-tap-highlight-color:rgba(0,0,0,0); /* prevent tap highlight color / shadow */ | |
| -webkit-user-select:none; /* prevent copy paste, to allow, change 'none' to 'text' */ | |
| } |
| backspace 8 | |
| tab 9 | |
| enter 13 | |
| shift 16 | |
| ctrl 17 | |
| alt 18 | |
| pause/break 19 | |
| caps lock 20 | |
| escape 27 | |
| page up 33 |
| // DOM Highlight (Ctrl-i) | |
| $(function() { | |
| $("<style type='text/css'> .DOMHighlight {background: rgba(0,0,0,0.1);} </style>").appendTo("head"); | |
| $('body').keypress(function(e) { | |
| if (e.which === 9) | |
| $('*').toggleClass('DOMHighlight'); | |
| }); | |
| })(); |
| function simulateEvent(element, type) { | |
| // Check for createEventObject | |
| if(document.createEventObject){ | |
| // Trigger for Internet Explorer | |
| trigger = document.createEventObject(); | |
| element.fireEvent('on' + type, trigger); | |
| } | |
| else { | |
| // Trigger for the good browsers | |
| trigger = document.createEvent('HTMLEvents'); |
| function syntaxHighlight(json) { | |
| if (typeof json != 'string') { | |
| json = JSON.stringify(json, undefined, 2); | |
| } | |
| json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); | |
| return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) { | |
| var cls = 'number'; | |
| if (/^"/.test(match)) { | |
| if (/:$/.test(match)) { | |
| cls = 'key'; |