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 / functions.php
Created June 4, 2015 09:30
Woocommerce - Non-admins shouldn't be able to see wordpress
<?php
// Non-admins can't login, they're redirected to the video/videos page,
// which stops them from messing with the website.
$goodbye = site_url();
function force_login_redirect( $redirect_to, $request, $user ) {
return ( is_array( $user->roles ) && in_array( 'administrator', $user->roles ) ) ? admin_url() : $goodbye;
}
add_filter( 'login_redirect', 'force_login_redirect', 10, 3 );
@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();
@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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;
}