Skip to content

Instantly share code, notes, and snippets.

View tylerthebuildor's full-sized avatar
💭
Hello World!

Tyler tylerthebuildor

💭
Hello World!
View GitHub Profile
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
@tylerthebuildor
tylerthebuildor / gist:5bf40927a3af789f8843
Created March 15, 2015 01:35
generator-angular-gulp html5mode modrewrite
$ 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',
/**
* @providesModule TappyButtonApp
* @flow
*/
'use strict';
var React = require('react-native/addons');
var {
Bundler,
StyleSheet,
* {
-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' */
}

Contract Killer

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

@tylerthebuildor
tylerthebuildor / JSKeyCodes
Created December 17, 2013 19:58
List of JavaScript key codes.
backspace 8
tab 9
enter 13
shift 16
ctrl 17
alt 18
pause/break 19
caps lock 20
escape 27
page up 33
@tylerthebuildor
tylerthebuildor / DOMHighlight.js
Created June 18, 2013 16:31
Adds transparent background to every node in the DOM. Allows for easy collision and overlap inspection. Ctrl-i toggles functionality.
// 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');
});
})();
@tylerthebuildor
tylerthebuildor / simulateEvent.js
Created May 27, 2013 18:36
Simulate JavaScript events
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');
@tylerthebuildor
tylerthebuildor / json-highlight.js
Created April 29, 2013 18:11
Adds span elements to parts of JSON string for post CSS manipulation.
function syntaxHighlight(json) {
if (typeof json != 'string') {
json = JSON.stringify(json, undefined, 2);
}
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
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';