Skip to content

Instantly share code, notes, and snippets.

View drifterz28's full-sized avatar

Chris Whitney drifterz28

View GitHub Profile
@drifterz28
drifterz28 / Equal Height
Created December 12, 2012 14:37
Set equal height of 2 tags
// set equal height with 2 tags
function set_height(div1, div2){
var height1 = $(div1).height();
var height2 = $(div2).height();
if(height1 > height2){
$(div2).css('min-height',height1);
}else{
$(div1).css('min-height',height2);
}
}
// paging code
// Query to count rows.
$result = mysql_query("SELECT * FROM Table_Name WHERE Column_Name = '$section'");
$items = 32; // number of items per page.
$all = $_GET['a']; //This is the view all param.
$num_rows = mysql_num_rows($result);
if($all == "all"){
$items = $num_rows;
}
@drifterz28
drifterz28 / error log
Created January 6, 2013 02:38
log errors in log file
@ini_set('log_errors','On');
@ini_set('display_errors','Off');
@ini_set('error_log','/home/example.com/logs/php_error.log');
@drifterz28
drifterz28 / Helper functions.js
Last active April 9, 2021 15:55
JavaScript Helper functions. Comments in code
// insert dom, does not reflow
var box2 = document.getElementById("box2");
box2.insertAdjacentHTML('beforebegin', '<div><p>This gets inserted.</p></div>');
/*
beforebegin
The HTML would be placed immediately before the element, as a sibling.
afterbegin
The HTML would be placed inside the element, before its first child.
beforeend
The HTML would be placed inside the element, after its last child.
@drifterz28
drifterz28 / Helpful htaccess snippets
Last active December 13, 2015 21:58
Helpful htaccess snippets that I have found over the years.
## mod rewrite control URI ##
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^.*$ ./index.php
## htaccess block all but listed IP's ##
order deny,allow
Array.prototype.unique = function (sort, sortingFunction) {
var array = [];
for (var i = 0; i < this.length; i++) {
if (array.inArray(this[i]) === false)
array.push(this[i]);
}
if (sort === true) {
if (typeof sortingFunction === 'function')
array.sort(sortingFunction);
else
@drifterz28
drifterz28 / Regex
Last active December 14, 2015 15:39
My Regex cheat sheet
-- remove DW template comments --
<!-- #(.*)-->
-- Find all non html5 doc types --
# has not been tested in the wild #
<\!DOCTYPE (html|HTML) (.*?\n?) (.*?)>
-- Find 4 or more of the same letter or number --
-- like aaaa bbbb or oolllloo --
/([a-z0-9])\1{4,}/i
@drifterz28
drifterz28 / CSS tricks
Last active December 15, 2015 17:19
My little book of css tricks, not the site.
* {
position: relative;
}
a {
transition: all 0.2s ease;
}
/* vertical align almost any element */
.vertical-align {
@drifterz28
drifterz28 / .htaccess
Last active December 17, 2015 11:19
HTaccess stuff.
## Include this at the start of your .htaccess file ##
Options +FollowSymlinks
RewriteEngine On
## Rewrites all .html pages to php pages with a 301 for seo
RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php [R=301,L]
## Disable the Server Signature ##
ServerSignature Off
@drifterz28
drifterz28 / WP help
Last active December 19, 2015 03:09
Wordpress function that I like to keep handy
// Remove ie style sheet and font if not needed for
// 2012 WP child theme
// source : http://wordpress.org/support/topic/twenty-twelve-submenu-not-working-in-internet-explorer?replies=19
function mytheme_dequeue_styles() {
wp_dequeue_style( 'twentytwelve-ie' );
wp_dequeue_style( 'twentytwelve-fonts' );
}
add_action( 'wp_enqueue_scripts', 'mytheme_dequeue_styles', 11 );
// widgets can use short codes