Skip to content

Instantly share code, notes, and snippets.

/**
* Pass in an element and its CSS Custom Property that you want the value of.
* Optionally, you can determine what datatype you get back.
*
* @param {String} propKey
* @param {HTMLELement} element=document.documentElement
* @param {String} castAs='string'
* @returns {*}
*/
const getCSSCustomProp = (propKey, element = document.documentElement, castAs = 'string') => {
@luetkemj
luetkemj / style.css
Created March 9, 2012 16:32
WP-CSS: Wordpress classes
/* =============================================================================
WordPress WYSIWYG Editor Styles
========================================================================== */
.entry-content img {
margin: 0 0 1.5em 0;
max-width: 100%;
height: auto;
}
.alignleft, img.alignleft {
@asuh
asuh / package.json
Last active December 19, 2019 21:11
NPM only, no Grunt, Gulp, Broccoli or Brunch
{
"name": "_s",
"version": "1.0.1",
"scripts": {
"clean": "rimraf style.css",
"notify": "notify -h",
"serve": "browser-sync start --proxy 'my.asuh' --files '**/*.css, **/*.js, *.php, **/*.json, dist/images/*'",
"imagemin": "imagemin src/images/* -o dist/images",
"icons": "svgo -f src/images/icons -o dist/images/icons && svg-sprite-generate -d dist/images/icons -o dist/images/icons/sprite.svg",
"lint-scss": "stylelint 'sass/**/*.scss' --syntax scss --config node_modules/stylelint-config-wordpress/scss.js",
@glaszig
glaszig / mkp2pblocklist
Last active January 30, 2022 00:30
creates a blocklist for your p2p endeavors
#!/usr/bin/env sh
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Copyright (C) 2020 glaszig <glaszig@gmail.com>
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
@cvan
cvan / useMedia-hook.js
Created July 1, 2020 20:15
useMedia - React hook for `window.matchMedia` for matching media-query
function useMedia(mediaQuery) {
const match = () => {
if (!window.matchMedia) {
return false;
}
return window.matchMedia(mediaQuery).matches;
};
const [value, set] = useState(match);
@panzerdp
panzerdp / decoratedFetch.ts
Last active September 18, 2022 23:51
An extensible fetch() implementation that uses the decorator pattern
type ResponseWithData = Response & { data?: any };
interface Fetcher {
run(input: RequestInfo, init?: RequestInit): Promise<ResponseWithData>;
}
class BasicFetcher implements Fetcher {
async run(input: RequestInfo, init?: RequestInit): Promise<ResponseWithData> {
return await fetch(input, init);
}
@WillBrubaker
WillBrubaker / remove-woocommerce-submenu-items
Last active November 22, 2022 13:34
Remove WooCommerce submenu items for Shop Managers
<?php
/*
Don't copy the opening php tag
*/
/*
Removes submenu items from WooCommerce menu for 'Shop Managers'
available submenu slugs are:
wc-addons - the Add-ons submenu
wc-status - the System Status submenu
@georgiecel
georgiecel / wp-comment-walker
Last active December 28, 2022 15:16
Custom comment walker for HTML5 friendly WordPress comment and threaded replies. To be inserted in functions.php.
<?php
class comment_walker extends Walker_Comment {
var $tree_type = 'comment';
var $db_fields = array( 'parent' => 'comment_parent', 'id' => 'comment_ID' );
// constructor – wrapper for the comments list
function __construct() { ?>
<section class="comments-list">
@davatron5000
davatron5000 / Sublime Text Setup.md
Last active April 15, 2023 15:39
A new user's guide to SublimeText 2. Estimated reading time: 2 mins. Estimated workthrough time: 12 minutes.

Make it useful

  • Install Package Control. For SublimeText 2, paste the following in Terminal:
import urllib2,os; pf='Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler( ))); open( os.path.join( ipp, pf), 'wb' ).write( urllib2.urlopen( 'http://sublime.wbond.net/' +pf.replace( ' ','%20' )).read()); print( 'Please restart Sublime Text to finish installation')

From here on out, use Package Control to install everything. +Shift+P, then type Install to get a list of installable packages you can 'livesearch through. After installing plugins, they should be running.

@bekarice
bekarice / filter-wc-orders-by-gateway.php
Last active August 3, 2023 13:37
Filters WooCommerce Orders by Payment Gateway Used
<?php
/**
* Plugin Name: Filter WooCommerce Orders by Payment Method
* Plugin URI: http://skyverge.com/
* Description: Filters WooCommerce orders by the payment method used :)
* Author: SkyVerge
* Author URI: http://www.skyverge.com/
* Version: 1.0.0
* Text Domain: wc-filter-orders-by-payment
*