Skip to content

Instantly share code, notes, and snippets.

View siffring's full-sized avatar

Jason Siffring siffring

View GitHub Profile
<!-- Add this between the <head></head> tags to influence how Facebook sees your site when someone shares it. -->
<meta name="title" content="This is the title of my site." />
<meta name="description" content="This is a description of my site." />
<link rel="image_src" href="http://mysite.com/logo.png" />
<?php
if ( arg(0) == 'node' && is_numeric(arg(1)) ) {
$node = node_load(arg(1));
print "node:" . $node->type;
} else {
print "not a node";
}
?>
// Save Form Field Prompts (jQuery)
//
// If you have form fields with default values like "Enter search term"
// this code will save that value, hide it when a user focuses on the field
// and restores it when they leave the field if they didn't enter anything.
// Select the fields you want to save
var $fields = $(".commentform textarea, .commentform input.text");
// No need to change anything below here
// wraps the first character of a paragraph with <div class="dropclass"></div>
// expects a jQuery paragraph object
// ex: dropCap($('.story p:first'));
function dropCap($target) {
$first_p = $target.html().trim(); // removes any leading whitespace
if ($first_p.charAt(0) != '<') {
// not a html tag
$target.html( '<div class="dropcap">' + $first_p.charAt(0) + '</div> ' + $first_p.substring(1) );
<!--
// Add these two meta tags to yourdomain.com.
// Now you can use yourdomain.com as your OpenID
// and authenticate using your Google account.
// Thanks: http://www.abstractioneer.org/2009/12/openid-delegation-for-googles-op.html
-->
<link rel="openid2.provider" href="https://www.google.com/accounts/o8/ud?source=profiles" >
<link rel="openid2.local_id" href="http://www.google.com/profiles/[your_google_profile_name]" >
@siffring
siffring / gist:946604
Created April 28, 2011 15:42
ExpressionEngine list of new members by month
{!-- Displays the number of new ExpressionEngine members by month --}
{exp:query sql="select count(*) AS total, month(from_unixtime(join_date)) as month, year(from_unixtime(join_date)) as year from exp_members group by year, month order by year DESC, month DESC"}
<br/>{year}-{month}: {total}
{/exp:query}
@siffring
siffring / function_as_parameter.js
Created October 7, 2011 18:14
Javascript: pass a function as a parameter to another function
// pass a function as a parameter of another function
function doAnotherThing() {
console.log('Doing another thing…');
}
function doSomething(callback) {
console.log('Doing something…');
if (typeof callback == 'function') {
callback.call();
@siffring
siffring / gist:1608761
Created January 13, 2012 21:20
How to sync Sublime Text 2 user packages using Dropbox
1) In your Dropbox directory, create a new directory called SublimeUserPackages
2) Open terminal
3) Go to Sublime's packages directory
cd ~/Library/Application Support/Sublime Text 2/Packages
4) Copy the user packages to your new dropbox folder
cp -rp User/* ~/Dropbox/SublimeUserPackages/
@siffring
siffring / .htaccess
Created March 4, 2012 17:33
htaccess to password protect a specific server
# ----------------------------------------------------------------------
# Password protect staging server
# Use one .htaccess file across multiple environments
# (e.g. local, dev, staging, production)
# but only password protect a specific environment.
# ----------------------------------------------------------------------
SetEnvIf Host staging.domain.com passreq
AuthType Basic
AuthName "Password Required"