Skip to content

Instantly share code, notes, and snippets.

View userabuser's full-sized avatar
💭
What's good?

userabuser

💭
What's good?
View GitHub Profile
@branneman
branneman / app.js
Last active February 5, 2021 21:58
Node.js application entry-point files
#!/usr/bin/env node
'use strict';
var spawn = require('child_process').spawn;
var args = [
'--harmony',
'app/bootstrap.js'
];
@franz-josef-kaiser
franz-josef-kaiser / MinFilterIterator.php
Last active January 18, 2021 19:15
An example plugin to show the use of the PHP SPL and subsidiary loops with a FilterIterator.
<?php
// Reduced to the minimum
class ThumbnailFilter extends FilterIterator
{
private $wp_query;
public function __construct( Iterator $iterator, WP_Query $wp_query )
{
NULL === $this->wp_query AND $this->wp_query = $wp_query;
parent::__construct( $iterator );
@bartholomej
bartholomej / css-media-queries-cheat-sheet.css
Last active October 8, 2025 08:02
CSS Media Query Cheat Sheet (with Foundation)
/*------------------------------------------
Responsive Grid Media Queries - 1280, 1024, 768, 480
1280-1024 - desktop (default grid)
1024-768 - tablet landscape
768-480 - tablet
480-less - phone landscape & smaller
--------------------------------------------*/
@media all and (min-width: 1024px) and (max-width: 1280px) { }
@media all and (min-width: 768px) and (max-width: 1024px) { }
@gorillawit
gorillawit / at-root.css
Last active February 8, 2018 13:37
Using @at-root directory to break nested selectors out of media queries and into the root level
/*
@at-root directory is a global sass function that allows @root can be called from
every nested media. @at-root refers to the base level so @at-root = the root that
all media-queries are bound too. ie for every nested media query, this is the
global style for them. NOW! we get to specify them in the latest Sass release,
@at-root: allows us to jump out of our context this is great if you have one
asset that needs to be different that than the others
*/
@media (min-width: 300px) {
.my-widget .inside-mq {
@branneman
branneman / better-nodejs-require-paths.md
Last active October 9, 2025 17:55
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@DevinWalker
DevinWalker / woocommerce-optimize-scripts.php
Last active August 5, 2025 09:32
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
@richnicholls404
richnicholls404 / gist:7449378
Last active October 27, 2020 06:09
Register Service Provider and assign a Facade alias programatically in Laravel (such as inside a package)
<?php namespace Cavedwellerrich\MyPackage;
use Illuminate\Support\ServiceProvider;
use Illuminate\Foundation\AliasLoader;
class MyPackageServiceProvider extends ServiceProvider {
//...
public function register()
@jcheng31
jcheng31 / Marginator.ahk
Last active February 20, 2024 23:45
An AutoHotkey script for widescreen, high-resolution monitors. Resizes the active window to be 75% of the screen's width (and 100% of its height, taskbar excluded) and centres it. Triggered by pressing Win+Shift+Up. Great for websites that don't nicely centre their content. Win+Shift+C now centres the active window without resizing it.
; When Win+Shift+Up is pressed, resize the active window to be 75% of the screen width
; and centre it. Useful for widescreen resolutions >= 1080p, but uses the resolution
; of the primary monitor.
#+Up::
SysGet, BoundingCoordinates, MonitorWorkArea
ResolutionWidth := BoundingCoordinatesRight - BoundingCoordinatesLeft
ResolutionHeight := BoundingCoordinatesBottom - BoundingCoordinatesTop
@ikkez
ikkez / jsreload-bookmarklet.js
Last active June 5, 2018 06:22
JSReload... is a simple tool to reload a specific javascript file and rollback any DOM changes that has been had since loading the page. Just include it in your page before the JS to reload, and call $.JSreload(); in your console. JSreload bookmarklet - a little script to place in your bookmarkbar that lets you reload a specific javascript file …
javascript: var JSreload={file:'',selector:'',rawContent:'',domContent:'',domElContent:'',init:function(){if(typeof jQuery==="undefined")
alert("jQuery not loaded.");else{jQuery(document).ready(function(){JSreload.displayPanel();JSreload.load();});};},load:function(){$.ajax(window.location.href,{async:false}).done(function(data){JSreload.rawContent=data;JSreload.domContent=$.parseHTML(data);});},run:function(){var date=new Date().getTime();JSreload.file=$('#JSreload-script').val();JSreload.selector=$('#JSreload-selector').val();if(JSreload.selector=='body'){JSreload.selector='#JSreload-body';var data=JSreload.rawContent.replace('<body','<body><div id="JSreload-body"').replace('</body>','</div></body>');JSreload.domElContent=$($.parseHTML(data)).filter('#JSreload-body').html();$('body').html(JSreload.domElContent);}else{JSreload.domElContent=$(JSreload.domContent).filter(JSreload.selector).html();$(JSreload.selector).html(JSreload.domElContent);}
$('head').append('<script class="JSreload" src="'+JSreload.file+
@PaulKinlan
PaulKinlan / criticalcss-bookmarklet-devtool-snippet.js
Last active March 12, 2025 01:22
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");