Skip to content

Instantly share code, notes, and snippets.

View mannieschumpert's full-sized avatar

Mannie Schumpert mannieschumpert

View GitHub Profile
@mannieschumpert
mannieschumpert / menu.js
Last active December 14, 2015 05:59
jQuery and Sass for the responsive toggling sidebar menu in the Blog portion of my site.
(function($) { // Use a wrapper since WordPress loads jQuery in noconflict mode
// Menu Toggling - NOTE: This part is easy to read but verbose. See refactored version linked in comments.
$(document).ready(function(){
// Store the elements, since we'll be using them repeatedly
var open = $(".toggle.open");
var close = $(".toggle.close");
var nav = $(".sidenav");
var sidebar = $(".sidebar");
@mannieschumpert
mannieschumpert / gist:5126935
Last active December 14, 2015 18:09
Fancybox styles Sass-ified
/*! fancyBox v2.1.4 fancyapps.com | fancyapps.com/fancybox/#license */
.fancybox-wrap,
.fancybox-skin,
.fancybox-outer,
.fancybox-inner,
.fancybox-image,
.fancybox-wrap iframe,
.fancybox-wrap object,
.fancybox-nav,
.fancybox-nav span,
@mannieschumpert
mannieschumpert / menu.js
Created March 19, 2013 13:52
Refactored version of my menu-toggling script.
(function($) { // Use a wrapper since WordPress loads jQuery in noconflict mode
// Menu Toggling
$(document).ready(function(){
var sidebar = $(".sidebar");
$(".toggle").click(function(){
var $this = $(this);
if ($this.hasClass('open') ){sidebar.toggleClass("active");}
$(".sidenav").toggleClass("inactive");
$cols: 12
$gutter: 2%
$one_col: (100% - ($gutter * ($cols - 1))) / $cols
@mixin cols($num)
width: ($one_col * $num) + ($gutter * ($num - 1))
@mixin sub_cols($num_child, $num_parent)
@mannieschumpert
mannieschumpert / gist:5321261
Created April 5, 2013 17:53
Inspired by the Sass Pt.2 course on CodeSchool.com, this Sass mixin gist also adds a parameter to adjust the size of the "caret".
=caret($point,$size)
$opposite: opposite-position($point)
border: $size solid transparent
border-#{$opposite}: $size solid #000
border-#{$point}: 0
height: 0
width: 0
@mannieschumpert
mannieschumpert / gist:5321866
Last active December 15, 2015 20:58
Sass absolute positioning mixin demo
// Gist at https://gist.github.com/mannieschumpert/5321866
// Future enhancements: support all four direction attributes (probably needs a different technique to avoid verboseness)
// Sass v3.2.7
=absolute($args: NULL)
position: absolute
@if $args != NULL
#{nth($args, 1)}: nth($args, 2)
@if length($args) == 4
#{nth($args, 3)}: nth($args, 4)
@mannieschumpert
mannieschumpert / gist:5344974
Last active December 16, 2015 00:09
A simple PHP function to print copyright date
function copyright($start, $owner) {
$date = date('Y');
echo "© Copyright ";
if ( $start < $date ) {
echo "{$start} - ";
}
echo "{$date} {$owner}";
}
/*
@mannieschumpert
mannieschumpert / Get&Set Multisite Blog Option Transients.md
Last active December 16, 2015 10:28
Gets/stores a transient set to an array of blog option meta for sites across a multisite network.

Network-wide queries are very costly, performance-wise. If you need to get or display lists of per-blog meta values network-wide, it's better to save it as a transient so that the query doesn't bog down the site.

####To Do:

  • remove $time parameter, and just set the expiry far in the future
  • call delete_site_transient whenever a site is added or has its status changed, or when a site modifies the specified meta
@mannieschumpert
mannieschumpert / gist:5855129
Last active December 18, 2015 22:29
Bash function for initializing a WordPress theme repo and setting it up to receive push. Directories are of course specific to my workflow. Change as necessary. (Note: works with HostGator. I'm not sure if it works universally.) Git-specific info via @mexitek. http://www.arlocarreon.com/blog/git/push-git-repo-into-shared-hosting-account-like-hos…
devinit() {
# move to dev themes
cd public_html/dev/wp-content/themes
# create theme directory
mkdir ${1}
# move into it
cd ${1}
#initialize git
git init
# configure for receiving pushes
@mannieschumpert
mannieschumpert / gist:6127173
Last active December 20, 2015 11:59
Generate a random number of a given length in PHP.
<?php
// how long the string should be
$length = 8;
$num = '';
for ($i = 0; $i < $length; $i++) {
$num .= mt_rand(0, 9);
}