Skip to content

Instantly share code, notes, and snippets.

View stormwarning's full-sized avatar
👀

Jeff stormwarning

👀
View GitHub Profile
/**
* Vertically center an element's children.
*/
%vertical-center {
display: table;
> * {
display: table-cell;
vertical-align: middle;
}
@stormwarning
stormwarning / is-visible.js
Last active June 6, 2020 22:10
Change an element's class when it comes into view.
/**
* Change class when element is in view
*/
var elementTop = $(".container").offset().top;
$(window).on("scroll", function updateClassWhenInView() {
if ($(window).scrollTop() > elementTop - window.innerHeight * 0.9) {
$(window).off("scroll", updateClassWhenInView);
$(".element").removeClass("is-hidden").addClass("is-visible");
}
/**
* Cross-browser image desaturation filter
*
* 1. Chrome 19+, Safari 6+, Safari 6+ iOS
* 2. Firefox 10+, Firefox on Android
* 3. IE6-9
*/
%greyscale {
-webkit-filter: grayscale(100%); /* [1] */
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* [2] */
@stormwarning
stormwarning / fb-numbers.php
Last active March 14, 2025 05:09
Return a count of Facebook Likes, Shares, Comments from Fan Pages.
<?php
/**
* Return the number of Likes, Shares, or Comments of a given Fan Page.
*/
function facebook_numbers( $url ) {
$fql = 'SELECT url, normalized_url, share_count, like_count, comment_count, ';
$fql .= 'total_count, commentsbox_count, comments_fbid, click_count FROM ';
$fql .= 'link_stat WHERE url = "' . $url . '"';
<?php
function _s_theme_options_init() {
register_setting(
'_s_options', // Options group, see settings_fields() call in _s_theme_options_render_page()
'_s_theme_options', // Database option, see _s_get_theme_options()
'_s_theme_options_validate' // The sanitization callback, see _s_theme_options_validate()
);
// Register our settings field group
add_settings_section(
@stormwarning
stormwarning / mixin--opacity.scss
Created January 17, 2014 23:36
Easy cross-browser opacity.
/**
* Cross-browser opacity.
*
* 1. Even IE8
*
* Usage:
*
@include opacity(0.8);
*
*/
@stormwarning
stormwarning / __constructs.html
Last active January 2, 2016 04:09
Semantic content constructs
<!--
Clean, efficient, complex content elements.
-->
@stormwarning
stormwarning / nir.css
Last active January 2, 2016 03:39
CSS image replacement using pseudo-elements.
/**
* Image replacement
*
* 1. Dimensions of replacement image
* 2. Fix for Firefox 2-
* 3. Required for IE8 if no `a:hover` styles declared
*
* Usage:
<a class="nir" href="[url]">[text]</a>
*
@stormwarning
stormwarning / __wordpress.php
Last active October 9, 2024 00:24
WordPress PROTIPs
/**
* A selection of handy code snippets, plugins, and best practices for WordPress development.
*
*/
@stormwarning
stormwarning / mixin--rgba.scss
Last active December 29, 2015 20:39
Generate a colour value from an RGBa value.
/**
* A very simple, pragmatic Sass mixin for generating any property with an rgba() colour
* and its associated fallback (sourced from the original rgba() colour).
*
* Do not use if you require a fallback vastly different from the rgba().
*
* 1. Strip the alpha value and write out a solid rgb() color.
* 2. Drop the red, green, blue, and alpha paramaters into the relevant places.
*
h1 {