Skip to content

Instantly share code, notes, and snippets.

View jongrover's full-sized avatar

Jonathan Grover jongrover

View GitHub Profile
@jongrover
jongrover / functions.php
Created December 2, 2019 18:38 — forked from elimn/functions.php
MT | TEC | Change past event views to reverse chronological order
<?php
// Changes past event views to reverse chronological order
function tribe_past_reverse_chronological ($post_object) {
$past_ajax = (defined( 'DOING_AJAX' ) && DOING_AJAX && $_REQUEST['tribe_event_display'] === 'past') ? true : false;
if(tribe_is_past() || $past_ajax) {
$post_object = array_reverse($post_object);
}
@jongrover
jongrover / archive-product.php
Created April 8, 2019 20:43 — forked from peltopiri/archive-product.php
WooCommerce - Nested Category/Subcategory Layout, FIXED: show subcategory content
<?php
/**
* The Template for displaying product archives, including the main shop page which is a post type archive
*
* This template can be overridden by copying it to yourtheme/woocommerce/archive-product.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
@jongrover
jongrover / archive-product.php
Created April 8, 2019 20:43 — forked from torbentschechne/archive-product.php
WooCommerce - Nested Category/Subcategory Layout
<?php
/**
* The Template for displaying product archives, including the main shop page which is a post type archive
*
* This template can be overridden by copying it to yourtheme/woocommerce/archive-product.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
@jongrover
jongrover / app.js
Last active October 20, 2016 16:40
Code Snippets for Riot JS Bloggr App Tutorial
var posts = [{ title: "How Crocodiles Cross Oceans", article: "How did the world's largest living reptile, the saltwater crocodile, reach so many South Pacific islands separated by huge stretches of water despite being a poor swimmer? Apparently, like a surfer catching a wave, these goliaths can ride currents on the ocean surface to cross large areas of open sea, researchers now reveal. The saltwater or estuarine crocodile (Crocodylus porosus) is a ferocious giant that can grow at least 23 feet long (7 meters) and weigh more than 2,200 pounds (1000 kilograms). These scaly monsters have been known to devour sharks, and even attack things they can't eat, often assaulting boats in the mistaken belief they are rivals or prey, biting down with nearly 2 tons of pressure — powerful enough to crush bone or punch through aluminum hulls..." }, { title: "Lemur Species", article: "Exact classification of some types of lemurs is a subject of debate, but it's generally accepted that there are five families of lemurs with a
@jongrover
jongrover / functional-task-list.js
Last active September 27, 2016 17:28
Comparing Functional and Object Oriented patterns in JavaScript
var tasks = [];
function display() {
var output = "";
for(i=0; i < tasks.length; i++) {
output += (i+1) + ". " + tasks[i] + "\n";
}
alert(output);
}
@jongrover
jongrover / dog.js
Last active September 27, 2016 16:51
Comparing Classical Inheritance vs Prototypal inheritance in Ruby vs JavaScript
function Dog(name) {
this.name = name;
}
Dog.prototype.bark = function () {
return this.name + " says bark bark!"; // Storing things on the prototype will be accessible to all dogs but will only take up memory in a single place once time.
};
var dog1 = new Dog("Fido");
var dog2 = new Dog("Snoopy");
dog1.bark(); // Fido says bark bark!
@jongrover
jongrover / slim-redux.js
Created June 24, 2016 18:05 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
# Copy and paste this to the rails console to test your email settings
class MyMailer < ActionMailer::Base
def test_email
@recipients = "[email protected]"
@from = "[email protected]"
@subject = "test from the Rails Console"
@body = "This is a test email"
end
end
@jongrover
jongrover / hacker-radiio
Created March 15, 2016 11:59 — forked from jars/hacker-radiio
Music For Hackers
Music For Hackers
==
To a hacker, there's something distracting about booting up a GUI to listen to your tunes. You live your life in the terminal, you treat the mouse like a high voltage tap.
So give these commands a run in the terminal, and toss on your headphones.
sudo apt-get install mplayer
echo "alias defcon-start='nohup mplayer http://sfstream1.somafm.com:6200 > /dev/null 1>&2 &'" >> ~/.bashrc
echo "alias defcon-stop='killall -9 mplayer'" >> ~/.bashrc
@jongrover
jongrover / jquery.colorcycle-ordered.js
Created December 5, 2014 20:34
jQuery Color Cycle Plugin Modified to change colors in order instead of selecting colors randomly
/* jQuery Color Cycle Plugin - v0.1.1 - created by: [email protected] */
(function ($) {
$.fn.colorCycle = function( options ) {
var settings = $.extend({
colors: ['#ff0000', '#ff6600', '#ff9900', '#ffcc00', '#ffff00', '#ccff00', '#99ff00', '#66ff00', '#00ff66', '#00ff99', '#00ffcc', '#00ffff', '#00ccff', '#0099ff', '#0066ff', '#0033ff', '#0000ff', '#3300ff', '#6600ff', '#9900ff', '#cc00ff', '#ff00ff', '#ff00cc', '#ff0099', '#ff0066'],
animationStartRange: 1000,
animationEndRange: 2000,
loopStartRange: 1000,