Skip to content

Instantly share code, notes, and snippets.

View zeraphie's full-sized avatar

Izzy Skye zeraphie

View GitHub Profile
<?php
$consumerKey = /*CONSUMER KEY*/;
$consumerSecret = /* CONSUMER SECRET*/;
$authContext = stream_context_create(array(
'http' => array(
@zeraphie
zeraphie / breadcrumbs.php
Created March 8, 2016 11:31
Wordpress Breadcrumbs
<?php
/**
* Echos out the html for breadcrumbs
*
* @return string
*/
function get_breadcrumbs($separator = '>', $home_title = 'Homepage', $breadcrums_id = 'breadcrumbs', $breadcrums_class = 'breadcrumbs') {
// If you have any custom post types with custom taxonomies, put the taxonomy name below (e.g. product_cat)
$custom_taxonomy = '';
@zeraphie
zeraphie / is_prime.php
Created March 8, 2016 15:15
Test if a number is prime 1-liner
function is_prime($number) {
return !preg_match('/^1?$|^(11+?)\1+$/x', str_repeat('1', $number));
}
@zeraphie
zeraphie / todays_item.php
Created March 8, 2016 15:32
Get today's item from a list of items
function todays_item($arr){
$count = count($arr);
$number = floor(time() / 86400) % $count;
return $arr[$number];
}
$arr = array(
'One',
'Two',
'Three'
@zeraphie
zeraphie / excerptify.php
Created March 29, 2016 15:24
Make any text 'excerpty'
<?php
// Make any text 'excerpty'
function excerptify($text, $length = 140){
return trim(substr($text, 0, strpos($text, ' ', $length))) . '...';
}
@zeraphie
zeraphie / linkscroll.js
Last active April 6, 2016 15:50
Scroll ze links
var animations = {
onload: function(callback) {
document.readyState === 'interactive' || document.readyState === 'complete' ? callback : document.addEventListener('DOMContentLoaded', callback);
},
renderize: function(fps, render) {
var fpsInterval, startTime, now, then, elapsed;
fpsInterval = 1000 / fps;
then = Date.now();
startTime = then;
@zeraphie
zeraphie / highlighter.js
Last active August 9, 2016 12:50
MathJax variable highlighting logic
(function($){
// MathJax highlighting jQuery plugin
// Highlights variables that are related to each other
// i.e. all variables that are the same and have superscript
// Note: Variables that have subscript are treated as a different
// variable
$.fn.highlighter = function(opts){
// Override defaults
opts = $.extend({
color: '#08c',
@zeraphie
zeraphie / cell-highlight.css
Created July 1, 2016 13:13
CSS Only solution to highlighting the current row and column
table {
float: left;
overflow: hidden;
position: relative;
width: 100%;
z-index: 2;
}
table tr {
-webkit-transition: background-color 0.3s;
@zeraphie
zeraphie / gong.js
Created September 26, 2016 13:11
MAKE EVERYTHING ON A SITE GONG
(function(a){for(var b,c=document.createTreeWalker(document.querySelector("body"),NodeFilter.SHOW_TEXT,null,!1);b=c.nextNode();)b.nodeValue=a})('gong');
@zeraphie
zeraphie / build.sh
Created September 27, 2016 11:06
A simplified interaction to run gulp and git to deploy from a development site to gtilab/staging/live
#!/bin/bash
set -o nounset -o pipefail -o errexit
cd "$(dirname "$0")/../.."
################################################################################
# Master one liner interaction with deploying files
#
# Build the assets, then add and commit the files to git
# Then uploads the current branch to the live site, staging site and to GitLab
#