Skip to content

Instantly share code, notes, and snippets.

@mynameispj
mynameispj / somephp.php
Created September 27, 2012 14:13
PHP Error Reporting
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
?>
@mynameispj
mynameispj / targetIE.js
Created October 7, 2012 23:18
jQuery Snippet: Do something in a particular version of IE
$(document).ready(function() {
if ($.browser.msie) {
var browserType = $.browser;
//change 7.0 in the line below to 6.0, 8.0, 9.0, etc, depending on targeted version
if (browserType.version == 7.0) {
//do stuff
}
}
});
@mynameispj
mynameispj / .htaccess
Created October 9, 2012 02:03
htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond $1 !^(index\.php|css|img|js|fonts|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
@mynameispj
mynameispj / elementContainsOtherElement.js
Created October 17, 2012 20:50
jQuery - check if element has another element
$('#div').has('.other-div').length;
//returns 1 if it does, returns 0 if it doesn't
@mynameispj
mynameispj / getFilePath.php
Created October 31, 2012 22:43
Drupal 7 - Get Filepath for File or Image
$findTheFileURL = file_create_url($node->field_csv_file['und'][0]['uri']);
@mynameispj
mynameispj / page.tpl.php
Created December 8, 2012 22:48
Drupal Omega: Print region outside of section
//Your region won't be rendered if it doesn't have a zone. There is a work-around for your use-case. All the //regions that are not being printed get placed in $page['#excluded']. You can use hook_page_alter() to move a //region from there to the part of the $page array that gets forwarded to the templates.
//source: http://drupal.org/node/1200272
$page['my_new_region'] = $page['#excluded']['my_new_region'];
@mynameispj
mynameispj / htmlspecialchars.js
Created February 3, 2013 20:35
HTML Special Characters in jQuery
function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}
@mynameispj
mynameispj / props.txt
Created February 8, 2013 22:05
Simple sticky elements with no jQuery plugin
http://daigo.org/2011/09/quick-and-dirty-sticky-elements-when-scrolling-using-jquery/
@mynameispj
mynameispj / height.js
Created February 9, 2013 23:31
jQuery: get the height of an element and set that height as an inline style on said element
$(window).load(function(){
var height = jQuery('#your-element').outerHeight(true);
$('#your-element').css('height',mainContainerVXDHeight);
})
@mynameispj
mynameispj / Compass px to em
Created March 10, 2013 22:29 — forked from ijy/Compass px to em
Modified for SASS syntax...
@function em($target, $context: $base-font-size)
@if $target == 0
@return 0
@return $target / $context + 0em
$base-font-size: 16px