Skip to content

Instantly share code, notes, and snippets.

View nathansmith's full-sized avatar
😎
Ask me about free high fives!

Nathan Smith nathansmith

😎
Ask me about free high fives!
View GitHub Profile
@nathansmith
nathansmith / remove_style.js
Last active August 18, 2020 21:03
Remove inline styles
/*
Remove inline style="..."
Preserve hidden content.
Call the function like this:
var all = document.getElementsByTagName('*');
remove_style(all);
@nathansmith
nathansmith / rgb_hex.js
Last active September 4, 2015 05:24
Convert colors to RGB
/*
This will change:
"rgba(255, 255, 255)" or "#fff"
Into:
#FFFFFF
*/
@nathansmith
nathansmith / module_pattern_init.js
Created January 11, 2010 17:08
Init + Module Pattern JS
// JS Module Pattern:
// http://j.mp/module-pattern
// Redefine: $, window, document, undefined.
var APP = (function($, window, document, undefined) {
// Automatically calls all functions in APP.init
$(document).ready(function() {
APP.go();
});
@nathansmith
nathansmith / html_reset.css
Created January 28, 2010 00:02
Reset for HTML4 / HTML5
/* `XHTML, HTML4, HTML5 Reset
----------------------------------------------------------------------------------------------------*/
a,
abbr,
acronym,
address,
applet,
article,
aside,
@nathansmith
nathansmith / sanitize_tinymce_content.js
Created June 17, 2010 00:57
Sanitize TinyMCE Content
//
// While TinyMCE can strip out <script> tags,
// it does not remove inline JS event handlers.
//
// Example: onmouseover, onclick, etc.
//
// This should be included at the bottom of a page,
// contained inside an <iframe> to sandbox user-created
// content. The reason it is contained in an <iframe>
// is to prevent user-created CSS from affecting
Check if a site it running PHP by appending this query string...
?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000
Example:
http://php.net/?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000
@nathansmith
nathansmith / select_jump_list.js
Created August 13, 2010 04:09
Simple jQuery Jump List
$('select.jump_list').change(function() {
if (!this.value) {
return;
}
var url, url_len, last_char;
if (this.value.match('://')) {
window.top.location = this.value;
}
//
// Forces equal heights on a jQuery array.
//
equalize: function(jq_arr, min_height) {
if (!jq_arr.length) {
return;
}
function do_equalize() {
var tallest = min_height || 0;
/*
Utility helper classes, to
be sprinkled in as needed.
Mmm... sprinkles!
*/
/* `Text Align + Vertical Align
----------------------------------------------------------------------------------------------------*/
// Example of how to cache the result of an external jQuery Template.
// Inspired by this post...
// http://encosia.com/2010/10/05/using-external-templates-with-jquery-templates/
var person = {name: 'Dave'};
var person_tmpl;
$.get('_template.tpl.html', function(template) {
// Use converted string from remote file.