Skip to content

Instantly share code, notes, and snippets.

@karlhillx
karlhillx / macos_big_sur_homebrew_apache_php_mariadb_2020.md
Last active April 20, 2024 11:15
macOS Big Sur 11.0 Setup: Homebrew + Apache + PHP + MariaDB (Regularly updated)

macOS Big Sur 11.0 Setup: Homebrew + Apache + PHP + MariaDB

This document helps get your macOS development environment up and running with the latest versions of Homebrew, Apache, PHP, and MariaDB.

@dazecoop
dazecoop / attributes-as-options.php
Last active April 16, 2024 02:57
WooCommerce product attributes as selectable options without variations
<?php
/**
* List available attributes on product page in a drop-down selection
*/
add_action('woocommerce_before_add_to_cart_button', 'list_attributes_on_product_page');
function list_attributes_on_product_page() {
global $product;
$attributes = $product->get_attributes();
@mtx-z
mtx-z / wp-bootstrap4.4-pagination.php
Last active April 4, 2023 12:55
Wordpress 5.4 Bootstrap 4.4 pagination (with custom WP_Query() and global $wp_query support) (UPDATED for Bootstrap 5: https://gist.github.com/mtx-z/af85d3abd4c19a84a9713e69956e1507)
<?php
/**
* @param WP_Query|null $wp_query
* @param bool $echo
* @param array $params
*
* @return string|null
*
* UPDATE for Bootstrap 5.0: https://gist.github.com/mtx-z/af85d3abd4c19a84a9713e69956e1507
*
@rhukster
rhukster / sphp.sh
Last active March 30, 2024 10:41
Easy Brew PHP version switching (Now moved to https://github.com/rhukster/sphp.sh)
#!/bin/bash
# Creator: Phil Cook
# Modified: Andy Miller
#
# >>> IMPORTANT: Moved to: https://github.com/rhukster/sphp.sh
# >>> Kept here for legacy purposes
#
osx_major_version=$(sw_vers -productVersion | cut -d. -f1)
osx_minor_version=$(sw_vers -productVersion | cut -d. -f2)
osx_patch_version=$(sw_vers -productVersion | cut -d. -f3)
@retlehs
retlehs / sync-prod.sh
Last active January 26, 2022 03:48
WP-CLI aliases sync example
read -r -p "Would you really like to reset your development database and pull the latest from production? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
wp @development db reset --yes &&
wp @production db export - > sql-dump-production.sql &&
wp @development db import sql-dump-production.sql &&
wp @development search-replace https://example.com https://example.dev
fi
@w00fz
w00fz / sphp.sh
Last active February 7, 2022 00:12
PHP switcher
#!/bin/bash
# Check if command was ran as root.
if [[ $(id -u) -eq 0 ]]; then
echo "The command \"sphp\" should not be executed as root or via sudo directly."
echo "When a service requires root access, you will be prompted for a password as needed."
exit 1
fi
# Usage
@alexwlchan
alexwlchan / settern_rss.py
Created February 14, 2016 08:44
Python script for creating a per-author RSS feed from iMore
#!/usr/bin/env python
"""
This script can be used to get a per-author RSS feed on iMore.com. It will try to
cache the entries, so the last 40 entries from an author will show up, even if
they're no longer in the main feed.
To invoke, just call this script at the command line:
python settern_rss.py
@rvl
rvl / git-pushing-multiple.rst
Created February 9, 2016 11:41
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

@jmny
jmny / migration.php
Last active December 14, 2023 04:44
phinx outside cli
// see also https://github.com/robmorgan/phinx/issues/364
$phinxApp = new \Phinx\Console\PhinxApplication();
$phinxTextWrapper = new \Phinx\Wrapper\TextWrapper($phinxApp);
$phinxTextWrapper->setOption('configuration', '/path/to/phinx.yml');
$phinxTextWrapper->setOption('parser', 'YAML');
$phinxTextWrapper->setOption('environment', 'development');
@JumpLink
JumpLink / timeline-responsive.less
Created October 7, 2014 12:07
rewritten bootstrap 3 responsive timeline css for less
/* rewritten bootstrap 3 responsive timeline css for less
* source: http://bootsnipp.com/snippets/featured/timeline-responsive
*/
.timeline {
list-style: none;
padding: 20px 0 20px;
position: relative;
&:before {
top: 0;
bottom: 0;