Skip to content

Instantly share code, notes, and snippets.

View nilovelez's full-sized avatar

Nilo Velez nilovelez

View GitHub Profile
@faisalman
faisalman / analytics-regexp.js
Created April 18, 2011 08:06
Regular Expression snippets to validate Google Analytics tracking code (in PHP, JavaScript)
/**
* Regular Expression snippets to validate Google Analytics tracking code
* see http://code.google.com/apis/analytics/docs/concepts/gaConceptsAccounts.html#webProperty
*
* @author Faisalman <movedpixel@gmail.com>
* @license http://www.opensource.org/licenses/mit-license.php
* @link http://gist.github.com/faisalman
* @param str string to be validated
* @return Boolean
*/
@dave1010
dave1010 / htaccess
Created December 14, 2011 13:07
HTTP Status Cats Apache (htaccess) config
# HTTP Status Cats
# Apache (htaccess) config created by @dave1010
# Licensed CC BY 2.0
# Images CC BY 2.0, from GirlieMac's photostream:
# http://www.flickr.com/photos/girliemac/sets/72157628409467125/with/6508023065/
# Usage: copy save this file as .htaccess or add it to your httpd.conf
ErrorDocument 404 '<a href="http://www.flickr.com/photos/girliemac/6508022985/" title="404 - Not Found by GirlieMac, on Flickr"><img src="http://farm8.staticflickr.com/7172/6508022985_b22200ced0.jpg" width="500" height="400" alt="404 - Not Found"></a>'
@westonruter
westonruter / filter-post-thumbnail-id.php
Last active January 5, 2023 06:42
How to filter the response for get_post_thumbnail_id()
<?php
/**
* How to filter the value that would be returned by get_post_thumbnail_id()
*/
add_filter( 'get_post_metadata', function ( $value, $post_id, $meta_key, $single ) {
// We want to pass the actual _thumbnail_id into the filter, so requires recursion
static $is_recursing = false;
// Only filter if we're not recursing and if it is a post thumbnail ID
@MikeNGarrett
MikeNGarrett / wp-3-8-replace-open-sans
Last active January 10, 2018 14:39
WordPress 3.8 - replace admin Open Sans font with your own version
function replace_open_sans() {
// Kill the original style
wp_deregister_style('open-sans');
// Replace it with your own (just as an example, I included only the 300 weight)
wp_register_style( 'open-sans', 'http://fonts.googleapis.com/css?family=Open+Sans:300' );
wp_enqueue_style( 'open-sans');
}
add_action( 'wp_enqueue_scripts', 'replace_open_sans' );
// Thanks to @timkinnane
add_action( 'admin_enqueue_scripts', 'replace_open_sans' );
@gosukiwi
gosukiwi / .vimrc
Last active February 24, 2020 06:01
.vimrc
" ---------------------- USABILITY CONFIGURATION ----------------------
" Basic and pretty much needed settings to provide a solid base for
" source code editting
" don't make vim compatible with vi
set nocompatible
" turn on syntax highlighting
syntax on
" and show line numbers
@qutek
qutek / functions.php
Last active October 31, 2023 07:03
[Wordpress] [Multisite] Get featured image by blog id on wordpress multisite
/* Get featured image */
if( !function_exists( 'get_the_post_thumbnail_by_blog' ) ) {
function get_the_post_thumbnail_by_blog($blog_id=NULL,$post_id=NULL,$size='post-thumbnail',$attrs=NULL) {
global $current_blog;
$sameblog = false;
if( empty( $blog_id ) || $blog_id == $current_blog->ID ) {
$blog_id = $current_blog->ID;
$sameblog = true;
}
@mandiwise
mandiwise / Update remote repo
Last active July 11, 2024 17:32
Transfer repo from Bitbucket to Github
// Reference: http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/
// See also: http://www.paulund.co.uk/change-url-of-git-repository
$ cd $HOME/Code/repo-directory
$ git remote rename origin bitbucket
$ git remote add origin https://github.com/mandiwise/awesome-new-repo.git
$ git push origin master
$ git remote rm bitbucket
@mjmeyer
mjmeyer / http-cat-error-pages.conf
Created February 17, 2016 22:58
Http.cat erorr pages for nginx
# ---------- Status Cats Error Pages!!! via: https://http.cat/ ---------
#
# requires that a dns resolver be set for nginx as in: resolver 127.0.0.1;
# typically uses dnsmasq for 127.0.0.1 resolver
#
# Usage:
# place this file somewhere accessible to nginx. /etc/nginx/snippets is a decent choice.
# then inside the server block(s) you want cat themed error status responses do:
# include snippets/http-cat-error-pages.conf
#
@champsupertramp
champsupertramp / Ultimate Member - adding custom fields in account page and tab
Last active October 14, 2023 19:18
Ultimate Member - adding custom fields in account page and tab
<?php
/* Add fields to account page */
add_action('um_after_account_general', 'showExtraFields', 100);
function showExtraFields()
{
$custom_fields = [
"alternate_email" => "Permanent E-mail Address",
"major" => "Major",
"minor" => "Minor",
"gpa" => "GPA",
@kontikidigital
kontikidigital / htaccess-redsys
Last active October 14, 2018 15:44
WooCommerce: Error Redsys con SSL
#Al tener un SSL con SNI o Let's Encrypt, redsys no devuelve bien el estado del pedido pago y lo deja "En Espera"
#Esto se produce porque redsys no es compatible con estos protocolos, por lo tanto hay que saltear el https: en la
#respuesta de redsys. La solución es en el plugin (https://wordpress.org/plugins/woocommerce-sermepa-payment-gateway/)
#elegir el Protocolo para notificaciones HTTP y en el .htacces añadir una exclusión a la regla que redirige de
#HTTP a HTTPS.
# Enviar trafico HTTP a HTTPS
RewriteEngine On
# Si la cadena de consulta no contiene wc-api=WC_MyRedsys
RewriteCond %{QUERY_STRING} !wc-api=WC_MyRedsys [NC]