Skip to content

Instantly share code, notes, and snippets.

View rolandinsh's full-sized avatar
🧔
Remote developer (LEMP, Node.js, Neo4j [graph])

Rolands rolandinsh

🧔
Remote developer (LEMP, Node.js, Neo4j [graph])
View GitHub Profile
@rolandinsh
rolandinsh / google-plus-feed.php
Created June 25, 2012 13:28 — forked from ocean90/google-plus-feed.php
WordPress Page Template to build a feed of your Google+ stream
<?php
/**
* Template Name: Google+ Feed
*/
/**
* A WordPress page template for a Google+ feed.
*
* @author Dominik Schilling
@rolandinsh
rolandinsh / fbcbfwss.php
Created June 30, 2012 02:46 — forked from ocean90/fbcbfwss.php
Filename-based cache busting for WordPress scripts/styles.
<?php
/**
* Filename-based cache busting for WordPress scripts/styles.
*
* Extend your .htaccess file with these lines:
*
* <IfModule mod_rewrite.c>
* RewriteEngine On
* RewriteBase /
*
@rolandinsh
rolandinsh / endpoints.php
Created July 12, 2012 06:52 — forked from joncave/endpoints.php
WP_Rewrite endpoints demo
<?php
/*
Plugin Name: WP_Rewrite endpoints demo
Description: A plugin giving example usage of the WP_Rewrite endpoint API
Plugin URI: http://make.wordpress.org/plugins/2012/06/07/rewrite-endpoints-api/
Author: Jon Cave
Author URI: http://joncave.co.uk/
*/
function makeplugins_endpoints_add_endpoint() {
<?php
/*
Plugin Name: Test
*/
class My_Like_Button {
function __construct()
{
$this->hooks();
}
@rolandinsh
rolandinsh / gist:3263895
Created August 5, 2012 10:58 — forked from kloon/gist:2376300
WooCommerce Automatically add product to cart on site visit
/*
* goes in theme functions.php or a custom plugin
**/
// add item to cart on visit
add_action( 'init', 'add_product_to_cart' );
function add_product_to_cart() {
if ( ! is_admin() ) {
global $woocommerce;
$product_id = 64;
$found = false;
<?php
if ( ! function_exists( 'ucc_nav_menu_css_class' ) ) {
function ucc_nav_menu_css_class( $classes, $item, $args ) {
$class = sanitize_title( $item->title );
$classes[] = 'menu-item-' . $class;
return $classes;
} }
add_filter( 'nav_menu_css_class', 'ucc_nav_menu_css_class', 10, 3 );
via http://wordpress.stackexchange.com/questions/2623/include-custom-taxonomy-term-in-search/5404#5404
function atom_search_where($where){
global $wpdb;
if ( is_search() )
$where .= "OR (t.name LIKE '%".get_search_query() . "%' AND {$wpdb->posts} . post_status = 'publish')";
return $where;
}
@rolandinsh
rolandinsh / ga-event-tracker.js
Created February 2, 2017 12:34 — forked from cheynewallace/ga-event-tracker.js
jQuery Google Analytics Event Tracking Using HTML Attributes
/*JSHint Options*/
/*global _gaq */
/*
Google Analytics Event Tracking - JSHint Checked
Written By Cheyne Wallace - 19th Nov 2012
Click Usage: <a href="http://somewhere"
class="ga-track"
event_category="Event Category"
event_action="Specific Action"
event_label="Optional Message"
@rolandinsh
rolandinsh / gist:170141e1add053ca9879064673a24a69
Last active February 6, 2017 00:51
Installing Neo4j on Ubuntu
cd ~
wget -O - http://debian.neo4j.org/neotechnology.gpg.key >> key.pgp
sudo apt-key add key.pgp
echo 'deb http://debian.neo4j.org/repo stable/' | sudo tee -a /etc/apt/sources.list.d/neo4j.list > /dev/null
sudo apt-get update && sudo apt-get install neo4j
sudo service neo4j (stop|start|restart)
@rolandinsh
rolandinsh / get_current_git_commit.php
Created May 10, 2017 00:06 — forked from stevegrunwell/get_current_git_commit.php
Get current git HEAD using PHP
<?php
/**
* Get the hash of the current git HEAD
* @param str $branch The git branch to check
* @return mixed Either the hash or a boolean false
*/
function get_current_git_commit( $branch='master' ) {
if ( $hash = file_get_contents( sprintf( '.git/refs/heads/%s', $branch ) ) ) {
return $hash;
} else {