Skip to content

Instantly share code, notes, and snippets.

@jukra
jukra / i2c.js
Last active September 28, 2015 07:41 — forked from rwaldron/i2c.js
var five = require('johnny-five'),
board, button;
board = new five.Board();
board.on("ready", function() {
board.sendI2CConfig();
var LSM303_CTRL_REG1_A = 0x20
, LSM303_CTRL_REG2_A = 0x21
@jukra
jukra / functions.php
Created August 7, 2015 06:45
WooCommerce remaining cost for free shipping notification
function cart_notice() {
$free_shipping_settings = get_option( 'woocommerce_free_shipping_settings' );
$maximum = $free_shipping_settings['min_amount'];
$current = WC()->cart->subtotal;
if ( $current < $maximum ) {
echo '<div class="woocommerce-message">Get free shipping if you order $ ' . ($maximum - $current) . ' more!</div>';
}
}
add_action( 'woocommerce_before_cart', 'cart_notice' );
@jukra
jukra / recentcomments.php
Created September 3, 2014 19:32
Wordpress recent comments
<?php
function my_recent_comments() {
$d = "j.n.Y H:i"; //Date format, set your own
$comments_query = new WP_Comment_Query();`
$comments = $comments_query->query( array( 'number' => '6', 'post_id' => '65', ) ); //How many comments and in which post
$comm = '';
if ( $comments ) : foreach ( $comments as $comment ) :
$comm .= '<li><a class="author" href="' . get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment->comment_ID . '">';
$comm .= get_comment_author( $comment->comment_ID ) . '</a> ';
$comm .= get_comment_date( $d, $comment->comment_ID ) .'</li>';