Skip to content

Instantly share code, notes, and snippets.

View langlers's full-sized avatar

Daniel Bond | Langlers WebWorks langlers

View GitHub Profile
@defunkt
defunkt / clients.md
Created April 18, 2010 14:09
A list of Gist clients.

Gist Clients

Want to create a Gist from your editor, the command line, or the Services menu? Here's how.

Editor Support

@strangerstudios
strangerstudios / gist:2185226
Last active April 16, 2021 01:15
Delete the WordPress User When a Paid Memberships Pro Member Cancels His Account
/*
Requires PMPro v1.4+
Code to delete WP user accounts when a member cancels their PMPro account.
Users are not deleted if:
(1) They are not cancelling their membership (i.e. $level_id != 0)
(2) They are an admin.
(3) The level change was initiated from the WP Admin Dashboard
(e.g. when an admin changes a user's level via the edit user's page)
*/
function my_pmpro_after_change_membership_level($level_id, $user_id)
@troy
troy / send_remote_syslog.php
Last active April 6, 2023 18:19
Send UDP remote syslog message from PHP (RFC 3164)
# replace PAPERTRAIL_HOSTNAME and PAPERTRAIL_PORT
# see http://help.papertrailapp.com/ for additional PHP syslog options
function send_remote_syslog($message, $component = "web", $program = "next_big_thing") {
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
foreach(explode("\n", $message) as $line) {
$syslog_message = "<22>" . date('M d H:i:s ') . $program . ' ' . $component . ': ' . $line;
socket_sendto($sock, $syslog_message, strlen($syslog_message), 0, PAPERTRAIL_HOSTNAME, PAPERTRAIL_PORT);
}
socket_close($sock);
@malarkey
malarkey / Contract Killer 3.md
Last active May 24, 2024 23:38
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………

@malarkey
malarkey / Three Wise Monkeys.md
Created December 2, 2012 14:26
Three Wise Monkeys (NDA)

Date: [date]

Between us [company name] and you [customer name].

Summary:

In short; neither of us will share any confidential information about each-other, by any means, with anyone else.

What’s confidential information?

@strangerstudios
strangerstudios / pmpro_cancel_on_next_payments_date.php
Last active May 20, 2021 11:17
Change PMPro membership cancellation to set expiration date for next payment instead of cancelling immediately.
/*
Change cancellation to set expiration date for next payment instead of cancelling immediately.
Assumes orders are generated for each payment (i.e. your webhooks/etc are setup correctly).
Since 2015-09-21 and PMPro v1.8.5.6 contains code to look up next payment dates via Stripe and PayPal Express APIs.
*/
//before cancelling, save the next_payment_timestamp to a global for later use. (Requires PMPro 1.8.5.6 or higher.)
function my_pmpro_before_change_membership_level($level_id, $user_id) {
//are we on the cancel page?
@danfinlay
danfinlay / How to download streaming video.md
Last active June 25, 2024 07:59
How to download a streaming video with Google Chrome

How to download streaming video

Streaming just means a download that they don't want you to keep. But Chrome's developer tools make it easy to access what's really going on under the hood.

Open Developer Tools

From the page where you want to download some things, go into your chrome menu to open the developer tools. You can either:

1.  (On a mac): Command-option-J
2. (On a PC): Control-alt-J
@strangerstudios
strangerstudios / assign_pmpro_level_to_role.php
Created February 18, 2014 16:11
Assign a Paid Memberships Pro level based on user role when user roles are updated.
function assign_pmpro_level_to_role($user_id, $role, $old_roles)
{
//we found a role related to pmpro level
if($role == "pmpro_level_1")
{
pmpro_changeMembershipLevel(1, $user_id);
}
elseif($role == "administrator")
{
pmpro_changeMembershipLevel(2, $user_id); //setup level 2 as an all access role or just give them level 1
@james2doyle
james2doyle / jquery-ga-form-submit.js
Created August 5, 2015 18:06
jQuery contact form submit with Google Analytics event
$('#contact-form').submit(function(e) {
// delay the submit
e.preventDefault();
// we need this to call the form in a scoped function
var self = this;
ga('send', {
eventAction: "submit",
eventCategory: "form",
eventLabel: "contact-form",
hitType: "event",
@paulirish
paulirish / what-forces-layout.md
Last active June 26, 2024 15:20
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent