Skip to content

Instantly share code, notes, and snippets.

View tzkmx's full-sized avatar
🎉
estrenando repositorios privados

Jesus Franco tzkmx

🎉
estrenando repositorios privados
View GitHub Profile
@tzkmx
tzkmx / counter-redux-example.js
Last active August 15, 2016 01:22
React-Redux standalone in browser (no browserify, no webpack, just plain <script> tags)
// React component
var Counter = React.createClass( {
render: function() {
var value = this.props.value;
var onIncreaseClick = this.props.onIncreaseClick;
return (
React.createElement("div", null,
React.createElement("span", null, value),
React.createElement("button", {onClick: onIncreaseClick}, "Increase")
)
@tzkmx
tzkmx / jquery-redux-example.js
Created August 11, 2016 23:40
Redux with jQuery simple example
// original from:https://codepen.io/mdd/pen/wGRqbw
// Reducer
const counter = (state = 0, actions) => {
switch (actions.type) {
case 'INCREMENT': return state + 1;
case 'DECREMENT': return state - 1;
default: return state
}
}
@tzkmx
tzkmx / 1fix-switch-theme-on-certain-pages.php
Created September 28, 2016 01:14 — forked from yoren/1fix-switch-theme-on-certain-pages.php
WordPress tiny plugin - Switch theme on certain pages
<?php
/**
* @package One_Fix_Switch_Theme
* @version 1.0
*/
/*
Plugin Name: One Fix Switch Theme
Plugin URI: https://www.1fix.io
Description: Switch theme on certain pages.
Author: Yoren Chang
@tzkmx
tzkmx / domain_nginxDomainSslForceRedirection.php
Created January 9, 2017 18:55
Custom templates Plesk Nginx + PHP-FPM (SSL Force redirection, no proxy through Apache)
<?php
/**
* @see /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainSslForceRedirection.php
* @var Template_VariableAccessor $VAR
* @var array $OPT
*/
?>
server {
listen <?php echo $OPT['ipAddress']->escapedAddress . ':' . $OPT['frontendPort']; ?>;
@tzkmx
tzkmx / README.md
Last active March 17, 2017 22:05
Filter function to fix uploads directory (customized WordPress paths)

Moving WordPress to custom subdirectory and customize its managed paths

This is a must-use plugin to fix your uploads paths (URL & directory), for advanced paths customization for your wordpress intallation.

  • WordPress is installed at /wp subdirectory.
//wp-config.php
define('WP_HOME', 'http://example.com');
define('WP_SITEURL', 'http://example.com/wp');
@tzkmx
tzkmx / center_youtube_iframe.php
Created January 31, 2017 23:51
Mini plugin to center Youtube iframes inserted with oEmbed in WordPress
<?php
/**
* @package Uploads_Media
* @version 0.1
* @see http://wordpress.stackexchange.com/a/50781/16301
*/
/*
Plugin Name: Center Youtube Iframe
Plugin URI: https://core.trac.wordpress.org/ticket/32920
Description: Wraps youtube iframe in a centered paragraph
@tzkmx
tzkmx / jail.local
Created February 3, 2017 20:35 — forked from Nihisil/jail.local
Send notifications to the Slack from fail2ban
...
action_with_slack_notification = %(banaction)s[name=%(__name__)s, port="%(port)$
slack[name=%(__name__)s]
action = %(action_with_slack_notification)s
...
@tzkmx
tzkmx / README.md
Last active February 16, 2017 23:28
Custom Perl Module for NginX in order to remove single URIs cached

Custom module to purge cached URIs

Let's suppose you have this fastcgi_cache config:

fastcgi_cache_path /var/run/nginx-cache levels=2:2 keys_zone=WORDPRESS:2048m inactive=120m;

By using this module, in order to purge a single cached uri you can use a query like:

curl localhost/invalid_cache/mydomain.com/my_uri
@tzkmx
tzkmx / nginx.md
Created February 16, 2017 23:33
Preserve cache busting without query strings for WordPress

With this simple plugin, your URLs will be stripped of their query string, but the version is preserved to allow for cache busting.

However you need instruct your webserver to strip the version added in order to let clients use the files.

    location ~ /Versioned/ {
        rewrite ^/Versioned/([^/]+)(/.*)(\.[0-9a-zA-Z]+)$ /$2$3 last;
    }
@tzkmx
tzkmx / Lazy Load FB Like
Created February 18, 2017 00:02 — forked from giacomopaita/Lazy Load FB Like
Lazy Load Facebook Like Box
$('.tab a').on('click', function(){
if ($(this).html() == 'FACEBOOK' && typeof xx == 'undefined') {
// DUMMY VARIABLE TO CALL THE FUNCTION ONLY THE FIRST TIME THE USER CLICKS THE TAB:
xx = 1;
(function(d, s, id) {
var js;
var fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;