Skip to content

Instantly share code, notes, and snippets.

@danieldogeanu
danieldogeanu / ExcludeDirectoriesWinSCP.md
Created August 7, 2019 19:16
How to exclude certain directories on FTP transfer in WinSCP.

To exclude directories in WinSCP open the application and do the following:

  1. From the Login window click Tools > Preferences...;
  2. In the Preferences window navigate to Transfer section in the left side;
  3. From the right side click Add... button;
  4. In the Add transfer settings preset window, add a title for your preset in the Preset description field;
  5. Make sure that Binary (archives, doc, ...) is selected under the Transfer mode section;
  6. Under the Other section, at the end of the File mask: field, click the Edit... button;
  7. Add your files to exclude in the Exclude files: field, one per line;
  8. Add your directories to exclude in the Exclude directories: field, one per line;
  9. Click OK to close the window and to add the file masks;
@sankarara
sankarara / monitor-off.ahk
Created March 23, 2016 14:29
AutoHotKey: Turn monitor off with a keyboard shortcut
; This is part of my AutoHotkey [1] script that turns off my monitor when I
; press Win+\.
; It also turns the screensaver on at the same time, so that Windows Live
; Messenger (and any other programs) know I am away.
; I don't have a password on my screensaver, so there is a second version
; (Win+Shift+\) that locks the PC as well.
; Note: Sometimes the monitor comes back on after a second and I have to
@danieliser
danieliser / metabox-display-fields.php
Created December 21, 2015 06:54
​Replace line 277 of popup-maker/includes/admin/popups/metabox-display-fields.php with
<input type="checkbox" value="1" name="popup_display_position_fixed" id="popup_display_position_fixed" <?php checked( $position_fixed, 1 ); ?>/>
@psyrendust
psyrendust / elementChange.js
Created November 17, 2015 20:44
Add and remove MutationObserver events to a registered DOM element.
/**
* @typedef MutationCallback
* @param {NodeList} addedNodes A NodeList of elements that have been added to the DOM.
* @param {NodeList} removedNodes A NodeList of elements that have been removed from the DOM.
*/
/**
* Add a MutationObserver to a DOM node.
*
* @example
*
@johnbillion
johnbillion / hierarchy.php
Last active June 22, 2023 23:05
ASCII WordPress Template Hierarchy
<?php
/*
WordPress Theme Template Hierarchy Last updated for WordPress 5.4
==================================
This diagram is partially simplified for legibility. To view the complete template hierarchy in use on your site see the
Template panel in the Query Monitor plugin.
@cdillon
cdillon / gist:31b4ccc4185dbd4b778b
Last active May 10, 2016 12:35
example of a custom form in WordPress using math Captcha plugin by BestWebSoft
// shortcode: [demo-form]
function demo_form_shortcode( $atts ) {
$name = '';
$email = '';
$company = '';
$errors = array();
if ( isset( $_POST['demo_form_submitted'] )
@justintadlock
justintadlock / register-post-type.php
Last active October 22, 2023 05:55
Help file when registering post types.
<?php
# Register custom post types on the 'init' hook.
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 1.0.0
* @access public
@strangerstudios
strangerstudios / pmpro-customizations.php
Last active October 8, 2018 19:39
Add some fields to checkout with PMPro Register Helper. Both PMPro and PMPro Register Helper must be installed and activated. Save this in your plugins folder and activate. You can also just copy the PHP parts to your active theme's functions.php or your own pmpro-customizations plugin.
<?php
/*
Plugin Name: PMPro Customizations (Register Helper Example)
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customizations for Paid Memberships Pro (Register Helper Example)
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
//we have to put everything in a function called on init, so we are sure Register Helper is loaded
@strangerstudios
strangerstudios / gist:5556801
Last active July 4, 2016 05:15
Replace backticks in WordPress posts, topics, replies, etc with <pre lang="PHP"></pre> so WP-Syntax will highlight it.
/*
Switch `` with <pre lang="PHP"></pre>
*/
function pmpro_code_wrap($content)
{
$content = preg_replace("/`(.*?)`/s", '<pre lang="PHP">$1</pre>', $content);
return $content;
}
add_filter("the_content", "pmpro_code_wrap", -1);
@strangerstudios
strangerstudios / gist:3678054
Last active August 31, 2020 17:21
Extend Expiration Dates For Renewed Memberships in Paid Memberships Pro
/*
Important note! This code is included in PMPro versions 1.5.7 and later.
Adding this code will add 2x the number of days to the end of the subscription.
*/
//if checking out for the same level, add remaining days to the enddate
function my_pmpro_checkout_level($level)
{
global $pmpro_msg, $pmpro_msgt;
//does this level expire? are they an existing user of this level?