Skip to content

Instantly share code, notes, and snippets.

@oskansavli
oskansavli / DecimalFormat.js
Created February 11, 2011 14:03
Javascript number formatter (Java DecimalFormat Implemented in Javascript)
/**
* @class DecimalFormat
* @constructor
* @param {String} formatStr
* @author Oskan Savli
*/
function DecimalFormat(formatStr)
{
/**
* @fieldOf DecimalFormat
@EricBusch
EricBusch / replace-buy-button-with-more-details.php
Created January 22, 2014 15:35
Replaces "Buy" button with "More Details" button on list of products (WooCommerce). For example on category pages.
<?php
/**
* Removes the "Buy" button from list of products (ex. category pages).
*/
add_action( 'woocommerce_after_shop_loop_item', 'mycode_remove_add_to_cart_buttons', 1 );
function mycode_remove_add_to_cart_buttons() {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
}
@barrykooij
barrykooij / pc-example.php
Created June 5, 2014 07:59
Post Connector Example: Display linked posts of current post
<?php
// Get the connected posts
$my_connected_posts = Post_Connector::API()->get_children( "course", get_the_id() );
// Check
if ( count( $my_connected_posts ) > 0 ) {
// Loop
foreach ( $my_connected_posts as $my_connected_post ) {
@claudiosanches
claudiosanches / message.txt
Created November 11, 2014 21:26
Google Analytics Data Privacy Message
You can prevent Google Analytics from tracking you by clicking the following link. An opt-out cookie will be set, which will prevent you being tracked when visiting this website in the future:
<a href="javascript:gaOptout()">Deactivate Google Analytics</a>.
@pwenzel
pwenzel / 404-error-tracking.html
Created February 20, 2015 05:19
Track 404 errors as events with Google Universal Analytics, capturing the referrer as well.
<script type="text/javascript">
// Track 404 errors with Universal Analytics
if($('body').hasClass('error404')) {
ga('send', 'event', 'error', '404', 'page: ' + document.location.pathname + document.location.search + ' ref: ' + document.referrer, {'nonInteraction': 1});
}
</script>
@hannob
hannob / wordpress-4.2-xss-emergency-fix.diff
Created April 27, 2015 14:52
Wordpress 4.2 XSS emergency fix
--- wordpress/wp-comments-post.php 2015-01-08 08:05:25.000000000 +0100
+++ htdocs/wp-comments-post.php 2015-04-27 16:50:24.250000000 +0200
@@ -12,6 +12,12 @@
exit;
}
+$psize=0;
+foreach($_POST as $p) {
+ $psize += strlen($p);
+}
@vancluever
vancluever / gnome-tracker-disable.md
Last active November 13, 2024 18:26
GNOME Tracker Disable

Disabling GNOME Tracker and Other Info

GNOME's tracker is a CPU and privacy hog. There's a pretty good case as to why it's neither useful nor necessary here: http://lduros.net/posts/tracker-sucks-thanks-tracker/

After discovering it chowing 2 cores, I decided to go about disabling it.

Directories

@rebeccacremona
rebeccacremona / .bash_profile
Created September 1, 2016 13:46
Eternal bash history
# No dupes
export HISTCONTROL=ignoreboth:erasedups
# Eternal bash history.
# ---------------------
# Undocumented feature which sets the size to "unlimited".
# http://stackoverflow.com/questions/9457233/unlimited-bash-history
export HISTFILESIZE=
export HISTSIZE=
export HISTTIMEFORMAT="%F %T "
@captainbrosset
captainbrosset / z-index.js
Created January 13, 2017 11:52
z-index tool - Compare 2 elements in the DOM and understand why they are stacked the way they are
(function() {
/**
* https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
*
* A stacking context is formed, anywhere in the document, by any element which is either
*
* - the root element (HTML),
* - positioned (absolutely or relatively) with a z-index value other than "auto",
* - a flex item with a z-index value other than "auto",that is the parent element display: flex|inline-flex,
* - elements with an opacity value less than 1. (See the specification for opacity),
@braian87b
braian87b / dumb-ap-wired-link.sh
Last active October 23, 2024 23:13
How to setup a Dumb AP, Wired backbone for OpenWRT / LEDE