Skip to content

Instantly share code, notes, and snippets.

@mynameispj
mynameispj / drupal_6_updateCache
Created March 16, 2012 16:21
Drupal 6 custom module to update all site caches
function z_masterfit_ui_customized_menu() {
$items = array();
$items['admin/flush-cache'] = array(
'type' => MENU_NORMAL_ITEM,
'title' => t('Flush the cache'),
'description' => 'Flush all website caches to make sure it updates to relect '.
'your recent changes.',
'page callback' => 'flush_cache_custom_callback',
'access callback' => user_access('flush cache'),
@mynameispj
mynameispj / gist:2237482
Created March 29, 2012 13:36
jQuery snippet to remove and replace default form input text on click
$('form.form-search input').focus(function() {
if (this.value == this.defaultValue){
this.value = '';
}
if(this.value != this.defaultValue){
this.select();
}
});
$('form.form-search input').blur(function() {
if ($.trim(this.value) == ''){
@mynameispj
mynameispj / states-ul
Created April 2, 2012 19:29
<ul> of all 50 states
<ul>
<li>AL<li>
<li>AK<li>
<li>AZ<li>
<li>AR<li>
<li>CA<li>
<li>CO<li>
<li>CT<li>
<li>DE<li>
<li>DC<li>
@mynameispj
mynameispj / gist:2292158
Created April 3, 2012 13:50
JS - force page to reload
window.location.reload(true);
@mynameispj
mynameispj / gist:2296224
Created April 3, 2012 23:17
Google Maps API JS
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyAOj_3CRyephdFtCbWh5OZ6eXa49zcJFHM&sensor=false"></script>
<div id="address" style="display:none;"><!--address for the map goes here-->8134 Country Village Drive Cordova, TN 38016</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
var geocoder;
function initialize() {
geocoder = new google.maps.Geocoder();
@mynameispj
mynameispj / hack.sh
Created April 4, 2012 13:32 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@mynameispj
mynameispj / node.tpl.php
Created April 5, 2012 19:45
Drupal 7 - $messages in node.tpl.php
global $global_messages;
print $global_messages;
@mynameispj
mynameispj / field-swap.js
Created May 15, 2012 20:30
Swap text input for password input on focus / blur
$('input').focus(function() {
if ($(this).hasClass('passwordLabel')) {
$(this).hide();
$(this).next('input').show();
$(this).next('input').focus();
}
if (this.value == this.defaultValue){
this.value = '';
}
@mynameispj
mynameispj / template.php
Created June 20, 2012 15:30
Drupal 7: add CSS files to certain nodes in template.php
function pj_preprocess_page(&$variables, $hook) {
//ADD TESTICULAR CANCER CSS TO FRONT PAGE
if (drupal_is_front_page()) {
drupal_add_css(drupal_get_path('theme', 'pj') . '/css/tc.css', array('group' => CSS_THEME, 'type' => 'file'));
}
// When this goes through the theme.inc some where it changes _ to - so the tpl name is actually page--type-typename.tpl
if (isset($variables['node'])) {
$variables['theme_hook_suggestions'][] = 'page__type__'. str_replace('_', '--', $variables['node']->type);
@mynameispj
mynameispj / scrollThatTable.js
Created July 7, 2012 20:58
Scrollable JS table fun time
<script type="text/javascript">
$(window).load(function () {
var isIE = $.browser.msie;
setTimeout(function () {
function sizeTableBrowser() {
$('.rgMasterTable.data').removeClass('data');
$('.rgMasterTable:visible').addClass('data');
var sitewidth = $('.ajax__tab_container:visible').width();