Skip to content

Instantly share code, notes, and snippets.

@manuelkiessling
manuelkiessling / generate-assets-manifest.php
Created December 21, 2017 12:23
Generate manifest.json file with hashes of all asset files in a folder, recursively
#!/usr/bin/env php
<?php
$path = realpath(__DIR__ . '/../web/assets');
$obsoletePrefix = realpath(__DIR__ . '/../web/') . '/';
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::KEY_AS_PATHNAME | RecursiveDirectoryIterator::FOLLOW_SYMLINKS));
$hashes = [];
@kloon
kloon / gist:4633463
Last active December 27, 2019 15:04
WooCommerce Disable Coupons on Sale Items
<?php
// Exclude coupons from being applied when products on sale
add_filter( 'woocommerce_coupon_is_valid', 'woocommerce_coupon_check_sale_items', 10, 2 );
function woocommerce_coupon_check_sale_items( $valid, $coupon ) {
global $woocommerce;
$valid_for_cart = $valid;
if (sizeof($woocommerce->cart->get_cart())>0) : foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) :
if ( function_exists( 'get_product') )
$product = get_product( $cart_item['product_id'] );
@anandgeorge
anandgeorge / app.js
Created May 27, 2012 16:15
Socket.io example with jquery and dom manipulation
var io = require('socket.io').listen(8000),
nicknames = {};
io.sockets.on('connection', function (socket) {
socket.on('user message', function (msg) {
socket.broadcast.emit('user message', socket.nickname, msg);
});
socket.on('nickname', function (nick, fn) {
if (nicknames[nick]) {