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 / balance.js
Created September 17, 2015 16:37
Balancing act: Getting your headings to even out when splitting into two or more lines
/* Pulled from this: https://github.com/adobe-webplatform/balance-text*/
!function(a,b){"use strict";var c=function(a,b,c){var d;return function(){function g(){c||a.apply(e,f),d=null}var e=this,f=arguments;d?clearTimeout(d):c&&a.apply(e,f),d=setTimeout(g,b||100)}};jQuery.fn[b]=function(a){return a?this.bind("resize",c(a)):this.trigger(b)}}(jQuery,"smartresize"),function(a){"use strict";function e(){this.reset()}var d,b=document.documentElement.style,c=b.textWrap||b.WebkitTextWrap||b.MozTextWrap||b.MsTextWrap||b.OTextWrap;e.prototype.reset=function(){this.index=0,this.width=0};var f=function(a,b){var e,c=/\s(?![^<]*>)/g;if(!d)for(d=[];null!==(e=c.exec(a));)d.push(e.index);return-1!==d.indexOf(b)},g=function(b){b.find('br[data-owner="balance-text"]').replaceWith(" ");var c=b.find('span[data-owner="balance-text"]');if(c.length>0){var d="";c.each(function(){d+=a(this).text(),a(this).remove()}),b.html(d)}},h=function(a){return b=a.get(0).currentStyle||window.getComputedStyle(a.get(0),null),"justify"===b.textAlign}
@yratof
yratof / functions.php
Created September 17, 2015 10:34
Change CTP single's parent from Blog to another page
<?php
// As of WP 3.1.1 addition of classes for css styling to parents of custom post types doesn't exist.
// We want the correct classes added to the correct custom post type parent in the wp-nav-menu for css styling and highlighting, so we're modifying each individually...
// The id of each link is required for each one you want to modify
// Place this in your WordPress functions.php file
function remove_parent_classes($class) {
// check for current page classes, return false if they exist.
return ($class == 'current_page_item' || $class == 'current_page_parent' || $class == 'current_page_ancestor' || $class == 'current-menu-item') ? FALSE : TRUE;
}
@yratof
yratof / compiled_grid.css
Created September 1, 2015 20:06
Grid for eivin using busy
/* Not so small grid.
How this grid works.
To start, give every grid item a class of `c`
*/
/*! END OF THE FUCKING GRID */
@yratof
yratof / meat.js
Created July 22, 2015 13:30
Inline Block space removal
// Inline block sorted out with javascript. Plain vanilla javascript.
// Technially, this removes unwanted nodes from inside a DOM node
var utils = {};
utils.clean = function(node) {
var child, i, len = node.childNodes.length;
if (len === 0) { return; }
// iterate backwards, as we are removing unwanted nodes
for (i = len; i > 0; i -= 1) {
child = node.childNodes[i - 1];
@yratof
yratof / pi.sh
Created July 21, 2015 17:04
eyepi
sudo apt-get install motion
sudo apt-get install ffmpeg
nano /etc/motion/motion.conf
#turnoff camera
webcam_localhost off
control_localhost off
width 640
height 640
@yratof
yratof / buy.rb
Last active August 29, 2015 14:24
Testing checkout pages with Watir
irb
require 'watir-webdriver'
b = Watir::Browser.new
b.goto 'http://demo.woothemes.com/canvas/shop/woo-single-1/'
b.button(:class => 'single_add_to_cart_button').click
b.goto 'http://demo.woothemes.com/canvas/checkout/'
b.text_field(:id => 'billing_first_name').set 'Andrew'
b.text_field(:id => 'billing_last_name').set 'Lazarus'
b.text_field(:id => 'billing_address_1').set '51 Sneinton Dale'
b.text_field(:id => 'billing_city').set 'Nottingham'
@yratof
yratof / active.js
Created June 30, 2015 14:33
Add state remove state to hovered items
jQuery(document).ready(function($){
$('.area').on('hover', function(){
$('.area').addClass('unwanted');
$(this).addClass('pick-me');
$(this).removeClass('unwanted');
});
$('.area').on('mouseleave', function(){
$('.area').removeClass('unwanted');
$('.area').removeClass('pick-me');
@yratof
yratof / gist:c3295a5bbf68641884c6
Created June 29, 2015 15:30
MySQL Fix for MAMP PRO when using WP CLI
sudo ln -s /Applications/MAMP/Library/bin/mysql /usr/local/bin/mysql;
sudo ln -s /Applications/MAMP/Library/bin/mysqlcheck /usr/local/bin/mysqlcheck;
sudo ln -s /Applications/MAMP/Library/bin/mysqldump /usr/local/bin/mysqldump
@yratof
yratof / gist:ce5f723b1d9b1ccfc1a3
Created June 24, 2015 14:53
Pull in SVG as object svg for Safari. Height etc.
<object class="svg" data-fallback="/library/images/icons/twitter.png">
<?php include_once(TEMPLATEPATH .'/library/images/icons/twitter.svg'); ?>
</object>
<style type="scss">
/* Responsive SVGs
Svgs don't like their ratio in safari. So we remove the browsers ability to
use it's own free will. Then we make the fucking thing work responsively. Neat! */
object.svg {
width: 100%;
@yratof
yratof / console.js
Created June 19, 2015 12:08
Inject jQuery into a side through console
var jq = document.createElement('script');
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
<!-- Wait! -->
jQuery.noConflict();