Skip to content

Instantly share code, notes, and snippets.

View yratof's full-sized avatar
🍊
Eating an orange

Andrew yratof

🍊
Eating an orange
View GitHub Profile
@yratof
yratof / Norwegian.scss
Last active April 4, 2016 12:37
Array of Norwegian words and their English sound
$misunderstandings: (
"abonner" : "a bonner", // Subscribe
"avfukter" : "I've fucked her", // Humidifier
"fagartikler" : "faggot tickler", // Profession articles
"Fagfolk" : "Fag folk" // Professionals
);
@yratof
yratof / .htaccess
Created January 6, 2016 10:41
Redirect Magento local media folder to live site. Saves you an hour of downloading media
RewriteEngine on
RedirectMatch 301 ^/media/wysiwyg/(.*) https://speider-sport.no/media/wysiwyg/$1
@yratof
yratof / menu-aim-min.js
Last active December 18, 2015 10:40
`Menu Aim` – Being forgiving when a user interacts with a large menu
!function(e){function t(t){var n=e(this),i=null,o=[],u=null,r=null,c=e.extend({rowSelector:"> li",submenuSelector:"*",submenuDirection:"right",tolerance:75,enter:e.noop,exit:e.noop,activate:e.noop,deactivate:e.noop,exitMenu:e.noop},t),l=3,f=300,a=function(e){o.push({x:e.pageX,y:e.pageY}),o.length>l&&o.shift()},s=function(){r&&clearTimeout(r),c.exitMenu(this)&&(i&&c.deactivate(i),i=null)},h=function(){r&&clearTimeout(r),c.enter(this),v(this)},m=function(){c.exit(this)},x=function(){y(this)},y=function(e){e!=i&&(i&&c.deactivate(i),c.activate(e),i=e)},v=function(e){var t=p();t?r=setTimeout(function(){v(e)},t):y(e)},p=function(){function t(e,t){return(t.y-e.y)/(t.x-e.x)}if(!i||!e(i).is(c.submenuSelector))return 0;var r=n.offset(),l={x:r.left,y:r.top-c.tolerance},a={x:r.left+n.outerWidth(),y:l.y},s={x:r.left,y:r.top+n.outerHeight()+c.tolerance},h={x:r.left+n.outerWidth(),y:s.y},m=o[o.length-1],x=o[0];if(!m)return 0;if(x||(x=m),x.x<r.left||x.x>h.x||x.y<r.top||x.y>h.y)return 0;if(u&&m.x==u.x&&m.y==u.y)return 0;var y
@yratof
yratof / branding-stylesheet.php
Last active December 1, 2020 19:41
Using ACF to create a stylesheet
<?php /* Brand Colour */ $colour = get_field( 'colour', 'option' ); ?>
.brand--background{ background-color: <?php echo $colour ?>; }
.brand--colour{ color: <?php echo $colour ?>; }
.brand--border{ border-color: <?php echo $colour ?>; }
@yratof
yratof / functions.php
Last active March 23, 2017 21:44
Woocommerce: Show % saved
<?php
/**
* Add save percent next to sale item prices,
* wrapped in a span + strong for CSS
* targeting with .saving{} and .saving strong{}
*/
add_filter( 'woocommerce_sale_price_html', 'woocommerce_sales_price_saving', 10, 2 );
function woocommerce_sales_price_saving( $price, $product ) {
$percentage = round( ( ( $product->regular_price - $product->sale_price ) / $product->regular_price ) * 100 );
@yratof
yratof / spacing.scss
Created December 2, 2015 12:55
Two forms of spaces. Large and small.
/**
* Apply spacing to elements throughout the site and keep it uniform.
* @param {[string]} $element: 'margin' [Margin or Padding]
* @param {[string]} $direction: 'top' [top, bottom, left, right, both or all]
* @param {[string]} $size: 'small' [small or large]
*/
$small_space: 2rem;
$large_space: 4rem;
@yratof
yratof / gruntfile.js
Created November 17, 2015 17:20
Latest gruntfile
module.exports = function(grunt) {
grunt.registerTask('watch', [ 'watch' ]);
grunt.initConfig({
// Make JS tiny
uglify: {
options: {
mangle: false
@yratof
yratof / list-slide.scss
Last active November 30, 2015 13:15
SCSS: Delayed sliding in list elements.
/*
* Animation and Timing Variables
*/
$element: '.menu-item'; // Pick element you want to animate
$length: 1s; // Length of animation
$stage: 0.05s; // Delay increments
$movement: 1rem; // How noticable the movment will be
$transition: cubic-bezier(0.175,0.885,0.32,1.275); // The animation easing
/*
@yratof
yratof / custom-search.php
Last active November 6, 2015 09:54
custom post type wordpress search
<form role="search" method="post" class="search-form padding-1" action="<?php echo home_url( '/' ); ?>">
<label>
<span class="screen-reader-text"><?php echo _x( 'Search for:', 'label' ) ?></span>
<input type="search" class="search-field" placeholder="<?php echo esc_attr_x( 'Search FAQs', 'placeholder' ) ?>" value="<?php echo get_search_query() ?>" name="s" title="<?php echo esc_attr_x( 'Search for:', 'label' ) ?>" />
<input class="post_type" type="hidden" name="post_type" value="frequent" />
</label>
<input type="submit" class="search-submit button brand" id="searchsubmit" value="<?php echo esc_attr_x( 'Search', 'submit button' ) ?>" />
</form>
@yratof
yratof / prefs.sublime-settings
Last active December 22, 2015 10:50
Sublime Settings
{
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/Color Schemes/Custom solarized (Dark).tmTheme",
"fade_fold_buttons": false,
"folder_exclude_patterns": [
".svn",
".git",
".hg",
"CVS",