Skip to content

Instantly share code, notes, and snippets.

View whalesalad's full-sized avatar
🖨️
PC LOAD LETTER

Michael Whalen whalesalad

🖨️
PC LOAD LETTER
View GitHub Profile
var Dialog = function() {
var self = this,
args = arguments;
self.init.apply(self, args);
};
window.Dialog = Dialog;
// show the overlay on the document for the darkness (fade it in)
<?php
/*
I use this function for every single WP project.
It's essentially a drop-in way for a surefire, reliable, primary navbar.
Pages with a -1 index aren't shown.
Sub-level pages aren't shown either, but if you're on a sub-page the parent is given an active class.
First and last links are given classes (useful for if you're adding separators to your menu)
It's legit.
<?php
// Handy little media function
function media($rsrc) {
return get_stylesheet_directory_uri().'/'.$rsrc;
}
// Helper function, accepts a string or an array of strings. Will spit out some css includes
function media_css($rsrc) {
if (is_array($rsrc)) {
<?php
// This code is bothering me, a lot
// Is there a flag or something that can be passed and/or an alternate
// method to do this so that each field is replaced with the same variable?!
Header(sprintf("Location: http://jetsuiteair.com?utm_source=%s&utm_medium=%s&utm_campaign=%s",
$post->post_name, $post->post_name, $post->post_name));
var SearchItem = function() {
var self = this,
args = arguments;
self.init.apply(self, args);
};
YY.SearchItem = SearchItem;
SearchItem.prototype = {
code in application_helper.rb:
def green_button_link(label, href)
'<a href="#{href}" class="btn green"><span>#{label}</span></a>'
end
code in html:
<%= green_button_link "New Charity", new_charity_path %>
@whalesalad
whalesalad / gist:2712758
Created May 16, 2012 18:17
Finds the largest image in the specified content region and sets it as the og:image meta attribute for FB sharing
$(window).load(function() {
var images = $('#contentinner').find('img'),
max_area = 0,
max_url = false;
for (i=0; i<=images.size()-1; i++) {
var img = $(images.get(i)),
url = img.attr('src'),
d = [img.width(), img.height()],
area = d[0] * d[1];
(function() {
var User;
User = (function() {
function User(user_data) {
this.name = user_data.your_name;
this.email = user_data.your_email;
this.has_facebook = user_data.has_facebook;
this.age = user_data.your_age;
module ApplicationHelper
def bootstrap_icon_label(label, icon, white)
white = ' icon-white' if white else ''
"<i class=\"icon-#{icon}#{white}\"></i> #{label}".html_safe
end
end
# Let's you do things like this:
# <%= link_to bootstrap_icon_label('New Program', 'plus', true), new_program_path, class: "btn btn-primary" %>
@whalesalad
whalesalad / gist:3187854
Created July 27, 2012 13:16
How unsubscribe should work

The Ideal Unsubscribe Flow

  • User clicks unsubscribe link in an email
  • User is immediately unsubscribed.
  • A message is displayed letting the user know that they'll be dearly missed.
  • A button is visible letting the user undo their unsubscribe action, in case they made a mistake.

Things to Avoid

  • User clicks unsubscribe from email