Skip to content

Instantly share code, notes, and snippets.

View mattyza's full-sized avatar
Focused

Matty Cohen mattyza

Focused
View GitHub Profile
@gedex
gedex / phpcs.xml
Last active September 10, 2020 10:11
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards">
<description>WooCommerce extension PHP_CodeSniffer ruleset.</description>
<!-- Exclude paths -->
<exclude-pattern>tests/</exclude-pattern>
<exclude-pattern>woo-includes/woo-functions.php</exclude-pattern>
<exclude-pattern>woo-includes/class-wc-dependencies.php</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
@georgestephanis
georgestephanis / limiter.php
Last active April 23, 2019 14:18
First, run `composer require google/apiclient:^2.0` on cli -- then get your credentials.json from the link in the file and drop this file in the folder. You WILL need to populate the two ID constants. They can be the same calendar if you really want, but I prefer to keep my blockers on a second hidden calendar to be tidier.
<?php
// credentials.json is gotten from https://developers.google.com/calendar/quickstart/php
define( 'EVENT_CALENDAR_ID', '' );
define( 'BLOCKER_CALENDAR_ID', '' );
define( 'WEEKS_TO_CHECK', 6 );
define( 'WEEKLY_LIMIT', 3 );
define( 'WEEK_IN_SECONDS', 7*24*60*60 );
define( 'TZ_P', substr_replace( trim( shell_exec( 'date +"%z"' ) ), ':', 3, 0 ) );
@kloon
kloon / btc-eth-luno-buy.php
Last active July 23, 2022 12:37
Luno.com "Dollar Cost Avg" daily buy script for BTC & ETH
<?php
/**
* Buy BTC & ETH daily on Luno.com
* @author Gerhard Potgieter <potgieterg@gmail.com>
* @since 2017-12-07
* https://www.luno.com/invite/JN5Z4
*
* This script will do a daily purchase of BTC and ETH on Luno.com based on rand value (ZAR) set. Default to R100 each. Why daily? https://en.wikipedia.org/wiki/Dollar_cost_averaging
*
* Installation Instructions
@iandunn
iandunn / phpmailer-send-via-mail.php
Created August 17, 2016 19:26
Disable PHPMailer sending via SMTP, so that MailCatcher can catch outbound messages from dev environments
/**
* Configure PHPMailer to send via PHP's mail()
*
* @param PHPMailer $phpmailer
*/
function phpmailer_send_via_mail( $phpmailer ) {
$phpmailer->IsMail();
}
add_action( 'phpmailer_init', 'phpmailer_send_via_mail', 999 );

Simple iDoneThis Alternative

This simple script is for logging all of the awesome things you do every day, using Terminal, and syncing them all to Dropbox. Nifty, right?

Installation

  • Grab the idid.sh file to a directory on your computer (tested with OS X).
  • Using Terminal, in the directory where you placed idid.sh, run the following commands:
  • mv idid.sh /usr/local/bin/idid.sh
@claudiosanches
claudiosanches / custom-my-account-endpoint.php
Last active November 6, 2023 20:10
Example of custom My Account endpoint.
<?php
class My_Custom_My_Account_Endpoint {
/**
* Custom endpoint name.
*
* @var string
*/
public static $endpoint = 'my-custom-endpoint';
@fdemiramon
fdemiramon / pre-commit
Created May 12, 2015 19:13
Pre-commit hook for git with phpcs and phpcbf (auto-correct obvious violations)
#!/bin/sh
PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"`
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`
# Determine if a file list is passed
if [ "$#" -eq 1 ]
then
oIFS=$IFS
IFS='
@milo
milo / github-webhook-handler.php
Last active July 26, 2023 15:29
GitHub Webhook Handler
<?php
/**
* GitHub webhook handler template.
*
* @see https://docs.github.com/webhooks/
* @author Miloslav Hůla (https://github.com/milo)
*/
$hookSecret = 's.e.c.r.e.t'; # set NULL to disable check

Installation

To install, you need to have the WordPress i18n library on your computer. Check it out using SVN:

sudo svn co http://i18n.svn.wordpress.org/tools/trunk/ /usr/lib/wpi18n

You don't have to put the library in /usr/lib/wpi18n, but if you don't put it there, make sure to set the $WP_I18N_LIB environment variable in your .bashrc or .bash_profile file (with no trailing slash):

export WP_I18N_LIB="/path/to/i18n/lib"

@Fab1en
Fab1en / custom_media_menu.js
Created January 21, 2013 15:32
Draft plugin example to add a javascript menu into the WP3.5 Media Library popup. Answer to this Wordpress stackexchange question : http://wordpress.stackexchange.com/questions/76980/add-a-menu-item-to-wordpress-3-5-media-manager/
// for debug : trace every event
/*var originalTrigger = wp.media.view.MediaFrame.Post.prototype.trigger;
wp.media.view.MediaFrame.Post.prototype.trigger = function(){
console.log('Event Triggered:', arguments);
originalTrigger.apply(this, Array.prototype.slice.call(arguments));
}*/
// custom state : this controller contains your application logic
wp.media.controller.Custom = wp.media.controller.State.extend({