Skip to content

Instantly share code, notes, and snippets.

View tylersticka's full-sized avatar

Tyler Sticka tylersticka

View GitHub Profile
@yannickcr
yannickcr / set.js
Created June 5, 2013 09:41
Handlebars Set Helper: Capture a block of content and store it in a variable.
/*
* Usages:
* {{#set "content"}}
* captured content
* {{/set}}
* My {{ content }}
*/
Handlebars.registerHelper('set', function(name, options) {
this[name] = options.fn(this);
return null;
@tsvensen
tsvensen / image-replacement.css
Last active December 23, 2019 11:46
Image Replacement Technique
/* http://www.zeldman.com/2012/03/01/replacing-the-9999px-hack-new-image-replacement/ */
overflow: hidden;
text-indent: 100%;
white-space: nowrap;
@stuntbox
stuntbox / gist:4557917
Last active March 23, 2023 03:32
Slightly smarter filtering to remove hard-coded width and height attributes from *all* images in WordPress (post thumbnails, images inserted into posts, and gravatars). Handy for responsive designs. Add the code below to the functions.php file in your theme's folder (/wp-content/themes/theme-name/ ). Remember to rename the function as needed to …
/**
* Filter out hard-coded width, height attributes on all images in WordPress.
* https://gist.github.com/4557917
*
* This version applies the function as a filter to the_content rather than send_to_editor.
* Changes made by filtering send_to_editor will be lost if you update the image or associated post
* and you will slowly lose your grip on sanity if you don't know to keep an eye out for it.
* the_content applies to the content of a post after it is retrieved from the database and is "theme-safe".
* (i.e., Your changes will not be stored permanently or impact the HTML output in other themes.)
*
@media only screen and (min-width: 320px) {
/* Small screen, non-retina */
}
@media
only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 320px),
@i-like-robots
i-like-robots / tmoauth-caching.php
Created August 29, 2012 08:45
Caching Tweets with tmhOAuth
<?php
class Tweets
{
/**
* Cached results as key => value array
*/
private static $cache = array();
@eknuth
eknuth / app.js
Created July 29, 2012 22:26
Google FastButtons as knockout.js custom binding
ko.applyBindings({
fastClickResult: ko.observable("Waiting..."),
clickResult: ko.observable("Waiting..."),
handleClick: function(self, event) {
self.clickResult("Clicked!");
},
handleFastClick: function(self, event) {
self.fastClickResult("Fast Clicked!");
}
});
@chriseppstein
chriseppstein / 0_usage.scss
Created February 29, 2012 19:29
This is code that runs using Sass 3.2 prerelease and something like this will be in compass soon.
@include keyframes(appear-and-roundify) {
0% { opacity: 0; @include border-radius(2px); }
100% { opacity: 1; @include border-radius(10px); }
}

Variadic argument support in LESS 1.3.0

.mixin (...) {        // matches 0-N arguments
.mixin () {           // matches exactly 0 arguments
.mixin (@a: 1) {      // matches 0-1 arguments
.mixin (@a: 1, ...) { // matches 0-N arguments
.mixin (@a, ...) {    // matches 1-N arguments
@peterwooley
peterwooley / mintty.reg
Created February 20, 2012 23:15
Assuming chere is insalled, this adds an "Open mintty Here" context menu option for Windows Explorer drives and folders.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\mintty]
@="Open mintty Here"
[HKEY_CLASSES_ROOT\Directory\shell\mintty\command]
@="c:\\cygwin\\bin\\mintty.exe -e /bin/xhere /bin/bash.exe \"%L\""
[HKEY_CLASSES_ROOT\Drive\shell\mintty]
@="Open mintty Here"
@ninnypants
ninnypants / remove-empty-p.php
Last active October 5, 2025 18:20
Remove empty p tags from WordPress posts
<?php
add_filter( 'the_content', 'remove_empty_p', 20, 1 );
function remove_empty_p( $content ){
// clean up p tags around block elements
$content = preg_replace( array(
'#<p>\s*<(div|aside|section|article|header|footer)#',
'#</(div|aside|section|article|header|footer)>\s*</p>#',
'#</(div|aside|section|article|header|footer)>\s*<br ?/?>#',
'#<(div|aside|section|article|header|footer)(.*?)>\s*</p>#',
'#<p>\s*</(div|aside|section|article|header|footer)#',