Skip to content

Instantly share code, notes, and snippets.

@jevgen
jevgen / docker-wordpress.sh
Created August 13, 2017 14:18 — forked from tatemz/docker-wordpress.sh
A quick way to get a WordPress installation up and running with Docker
#!/bin/bash
mkdir wordpress-site && cd wordpress-site
touch docker-compose.yml
cat > docker-compose.yml <<EOL
version: "2"
services:
my-wpdb:
@jevgen
jevgen / wp_mail.md
Created August 10, 2017 07:13 — forked from johnbillion/wp_mail.md
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This is accurate as of WordPress 4.8, and includes some upcoming changes in WordPress 4.9.

There are a few TODOs left. Please bear with me.

@jevgen
jevgen / gist:f78acc925ba9e1e9212a3a6941db5888
Created February 24, 2017 20:20
Set custom cookie upon completion of Gravity Form
function set_form_1_complete_cookie() {
setcookie( 'form-1-complete', 1, strtotime( '+30 days' ), COOKIEPATH, COOKIE_DOMAIN, false, false );
}
add_action( 'gform_after_submission_1', 'set_form_1_complete_cookie' );
@jevgen
jevgen / float2rat.js
Created January 19, 2017 18:18 — forked from anonymous/float2rat.js
JavaScript function to convert a floating point number into a ratio with the help of some continued fractions.
function float2rat(x) {
tolerance = 1.e-4;
h1=1; h2=0;
k1=0; k2=1;
b = x;
do {
a = Math.floor(b);
aux = h1; h1 = a*h1+h2; h2 = aux;
aux = k1; k1 = a*k1+k2; k2 = aux;
b = 1/(b-a);
@jevgen
jevgen / Gravity Forms Reset Styles
Created November 16, 2016 13:56 — forked from forgeandsmith/Gravity Forms Reset Styles
Gravity Forms SCSS reset styles for easy style editing and management
///////////////////////////////////////////////
////// GRAVITY FORMS RESET STYLES //////
///////////////////////////////////////////////
// These styles are made in mind to be used with SCSS or LESS
// If you use these styles, you must go to the Gravity Forms settings in the WordPress back end and set Output CSS to No.
////----- Core Containers
.gform_heading,
.gform_body,
@jevgen
jevgen / inline-validation.js
Created November 16, 2016 13:54 — forked from guyroutledge/inline-validation.js
Inline form validation with Gravity Forms
// if an invalid form field has been made valid,
// remove the shouty error highlighting - if a valid
// required field has been made invalid, start shouting
$('input, textarea, select').on('change', function(){
var $input = $(this);
var isRequired = $input.parents('.gfield').is('.gfield_contains_required');
var isValid = $input.is(':valid');
if ( isRequired && isValid ) {
@jevgen
jevgen / latency.markdown
Created October 9, 2016 14:47 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@jevgen
jevgen / gist:c9968b1c1f97763e829ab490514a83ad
Created October 8, 2016 20:27 — forked from clifgriffin/gist:8827396
Change comment notification recipient for Shopp products
<?php
add_filter('comment_notification_recipients', 'override_comment_notice_repicient', 10, 2);
function override_comment_notice_repicient($emails, $comment_id) {
$comment = get_comment( $comment_id );
if ( empty( $comment ) )
return $emails;
$post = get_post( $comment->comment_post_ID );
@jevgen
jevgen / gw-gravity-forms-map-fields-to-field.php
Created September 7, 2016 18:40 — forked from spivurno/gw-gravity-forms-map-fields-to-field.php
Gravity Wiz // Gravity Forms // Map Submitted Field Values to Another Field
<?php
/**
* Gravity Wiz // Gravity Forms // Map Submitted Field Values to Another Field
*
* Preview your Gravity forms on the frontend of your website. Adds a "Live Preview" link to the Gravity Forms toolbar.
*
* Usage
*
* 1 - Enable "Allow field to be populated dynamically" option on field which should be populated.
* 2 - In the "Parameter Name" input, enter the merge tag (or merge tags) of the field whose value whould be populated into this field.
@jevgen
jevgen / jquery.photoswipe.js
Created September 2, 2016 04:49 — forked from kshnurov/jquery.photoswipe.js
PhotoSwipe: init from DOM using jQuery
(function( $ ) {
$.fn.photoswipe = function(options){
var galleries = [],
_options = options;
var init = function($this){
galleries = [];
$this.each(function(i, gallery){
galleries.push({
id: i,