Skip to content

Instantly share code, notes, and snippets.

@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;
}
def explain!
puts 'Want to embed this Gist?'
puts 'Use this: <script src="http://gist.github.com/2059.js"></script>'
end
explain!
@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 / Props
Created July 24, 2012 14:55
Estimated reading time in PHP, by Brian Cray
Total props to Brian Cray: http://briancray.com/posts/estimated-reading-time-web-design/
@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;
}
@mynameispj
mynameispj / template.php
Created September 23, 2012 00:00
Drupal Preprocess Variables
function pj_preprocess_node(&$variables) {
//change ['pjtest'] to name of the variable you're creating
$variables['pjtest'] = 'PJ is Testing';
}
@mynameispj
mynameispj / getTag.js
Created September 25, 2012 17:50
Get an element's HTML tag with jQuery
$('.getMyHTMLTag')[0].tagName;
//returns 'P'
@mynameispj
mynameispj / rss-subscribers.sh
Created September 25, 2012 23:33
Bash script to parse Apache log for a count of RSS subscribers and email it to you
#!/bin/bash
# Schedule this to run once a day with cron. Doesn't matter what time since it parses yesterday's hits (by default).
# I only tested this on the Marco.org server, which runs CentOS (RHEL). No idea how it'll work on other distributions, but it's pretty basic.
# Required variables:
RSS_URI="/rss"
MAIL_TO="your@email.com"
LOG_FILE="/var/log/httpd/access_log"