Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonathan Grover jongrover

View GitHub Profile
@jongrover
jongrover / functions.php
Created Dec 2, 2019 — forked from elimn/functions.php
MT | TEC | Change past event views to reverse chronological order
View functions.php
<?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 Apr 8, 2019 — forked from peltopiri/archive-product.php
WooCommerce - Nested Category/Subcategory Layout, FIXED: show subcategory content
View archive-product.php
<?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 Apr 8, 2019 — forked from elbsurfer/archive-product.php
WooCommerce - Nested Category/Subcategory Layout
View archive-product.php
<?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 Oct 20, 2016
Code Snippets for Riot JS Bloggr App Tutorial
View app.js
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 Sep 27, 2016
Comparing Functional and Object Oriented patterns in JavaScript
View functional-task-list.js
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 Sep 27, 2016
Comparing Classical Inheritance vs Prototypal inheritance in Ruby vs JavaScript
View dog.js
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 Jun 24, 2016 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
View slim-redux.js
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])) {
View Rails Console Actionmailer test.rb
# Copy and paste this to the rails console to test your email settings
class MyMailer < ActionMailer::Base
def test_email
@recipients = "someone@somewhere.com"
@from = "must_be_same_as_smpt_account_login@gmail.com"
@subject = "test from the Rails Console"
@body = "This is a test email"
end
end
@jongrover
jongrover / hacker-radiio
Created Mar 15, 2016 — forked from jars/hacker-radiio
Music For Hackers
View hacker-radiio
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 Dec 5, 2014
jQuery Color Cycle Plugin Modified to change colors in order instead of selecting colors randomly
View jquery.colorcycle-ordered.js
/* jQuery Color Cycle Plugin - v0.1.1 - created by: jon@flatironschool.com */
(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,
You can’t perform that action at this time.