Skip to content

Instantly share code, notes, and snippets.

View jawinn's full-sized avatar

Josh Winn jawinn

View GitHub Profile
@jawinn
jawinn / euro_country_codes.js
Last active April 21, 2016 04:12
Array of Countries that Use the Euro (ISO Alpha-2 Country Codes)
// ===============================================================
// Array of countries using the Euro (ISO Alpha-2 country codes).
// *As of Jan, 2016.
// ===============================================================
var euro_users = {
// -- EU countries using the euro
'AT' : { name: 'Austria' },
'BE' : { name: 'Belgium' },
'CY' : { name: 'Cyprus' },
'EE' : { name: 'Estonia' },
@jawinn
jawinn / disable_yoast_xml_pinging.php
Last active October 9, 2018 05:28
Disable Yoast's Automatic XML Sitemap Pinging
<?php
// DISABLE YOAST's AUTOMATIC PINGING OF XML SITEMAP
add_filter('wpseo_allow_xml_sitemap_ping', '__return_false');
?>
@jawinn
jawinn / Fit Layer To Canvas.jsx
Created September 30, 2015 15:38
Fit Layer To Canvas - Photoshop Script
// FIT LAYER TO CANVAS
// via https://forums.adobe.com/message/5413957#5413957
var maintainAspectRatio;// set to true to keep aspect ratio
if(app.documents.length>0){
app.activeDocument.suspendHistory ('Fit Layer to Canvas', 'FitLayerToCanvas('+maintainAspectRatio+')');
}
function FitLayerToCanvas( keepAspect ){// keepAspect:Boolean - optional. Default to false
var doc = app.activeDocument;
var layer = doc.activeLayer;
// do nothing if layer is background or locked
@jawinn
jawinn / GroundChecker.cs
Last active July 15, 2023 03:24
Unity - Ground Checker: Get angle of sloped ground underneath the player
using UnityEngine;
using System;
// Finds the slope/grade/incline angle of ground underneath a CharacterController
public class GroundChecker : MonoBehaviour {
[Header("Results")]
public float groundSlopeAngle = 0f; // Angle of the slope in degrees
public Vector3 groundSlopeDir = Vector3.zero; // The calculated slope as a vector
@jawinn
jawinn / dark_responsive_menu.css
Created August 3, 2015 21:01
Severn - Dark responsive menu
/* CUSTOM CSS for Severn Theme - Use dark responsive menu, instead of white */
.nav-responsive { background:#000000; }
.nav-responsive .show-nav { color:#ffffff; }
.nav-responsive li a { color:#ffffff; }
.nav-responsive .lower hr { background:#313131; }
.nav-responsive li a:hover, .nav-responsive li a:focus { color:#B3B3B3; }
.nav-responsive li a:active,
.nav-responsive li.current-menu-item > a { color:#9DED2B; }
/* If logo is too small, increase max-height of logo image */
.nav-responsive .logo img { max-height:45px; }
@jawinn
jawinn / slope_under_simple.cs
Created August 3, 2015 06:06
Simple Method - Slope Under Player
private float groundSlopeAngle = 0f; // angle
private Vector3 groundSlopeDir;
// The controller hits a collider while performing a Move.
void OnControllerColliderHit (ControllerColliderHit hit)
{
Vector3 temp = Vector3.Cross(hit.normal, Vector3.down);
groundSlopeDir = Vector3.Cross(temp, hit.normal);
groundSlopeAngle = Vector3.Angle(hit.normal, Vector3.up);
}
@jawinn
jawinn / raycast_angle.cs
Last active August 29, 2015 14:26
Angle Between Hit Point of Two Raycasts (Unity)
// Determing angle of slope underneath character for various purposes.
[SerializeField]
private float groundSlopeAngle = 0f; // angle
private Vector3 groundSlopeDir;
private float slopeRaycastLength = 2.0f;
private float slopeRaycastSpread = 0.08f;
public bool IsSliding() {
return groundSlopeAngle > 50 || groundSlopeAngle < -50;
}
@jawinn
jawinn / PlayerController.cs
Created July 26, 2015 17:13
Unity Bare Bones Top-Down Controller C#
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed = 6.0F;
public float gravity = 20.0F;
private Vector3 moveDirection = Vector3.zero;
public CharacterController controller;
@jawinn
jawinn / list-subpages.css
Created June 26, 2015 03:22
WordPress - List Subpages + Heading
/* Only show 3rd tier submenu items when under that section! */
.children {
display: none;
}
.current_page_item .children,
.current_page_ancestor .children,
.current_page_parent .children {
display: block;
}
@jawinn
jawinn / functions.php
Last active August 29, 2015 14:16
WooCommerce - Get the "Shipping Multiple Addresses" extension's shipping_notes field to appear in order details, and email.
// Change "Delivery Notes" to what text you'd like to appear in both locations.
// Include other fields in order details
function modify_order_details($order){
echo "<p><strong>Delivery Notes:</strong><br>", get_post_meta( $order->id, '_shipping_notes', true ), "</p>";
}
add_action( 'woocommerce_admin_order_data_after_shipping_address', 'modify_order_details', 10, 1 );
// Add extra fields to order emails.
// This part is via http://docs.woothemes.com/document/add-a-custom-field-in-an-order-to-the-emails/