Skip to content

Instantly share code, notes, and snippets.

@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 / 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();
def explain!
puts 'Want to embed this Gist?'
puts 'Use this: <script src="http://gist.github.com/2059.js"></script>'
end
explain!
@mynameispj
mynameispj / custom-case-2.php
Last active October 7, 2015 02:27
Next / previous node links in Drupal 7
switch($n_node->type) {
case 'your-custom-content-type-machine-name-here':
$html = l('"'.$n_node->title .'"', 'node/'.$n_node->nid, array('html' => TRUE, 'attributes' => array('class' => array('prev-next'), 'title' => $n_node->title)));
return $html;
}
@mynameispj
mynameispj / post.html
Created July 12, 2012 22:21
512 Pixels Linked List CSS
<h2 class="entry-title">
<a href="web.html">
The title of an awesome post
<span class="glyph" href="web.html">&raquo;</span>
</a>
</h2>
@mynameispj
mynameispj / css.css
Created July 18, 2012 13:59
CSS hide text
.hide-text {
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
@mynameispj
mynameispj / script.js
Created August 2, 2012 17:17
Zebra striping table rows, resetting on specific table rows...
$('tbody > tr').each(function(){
if ($(this).hasClass('header')) {
counter=1;
} else {
if (counter == 1) {
$(this).addClass('even');
counter++;
} else if (counter == 2) {
$(this).addClass('odd');
counter--;
@mynameispj
mynameispj / center.css
Created September 3, 2012 23:57
<ol> or <ul> with centered <li>s
ul {
display: block;
width: 100%;
text-align: center;
}
li {
position: relative;
display: inline;
}