Skip to content

Instantly share code, notes, and snippets.

View janogarcia's full-sized avatar

Jano Garcia janogarcia

View GitHub Profile
@janogarcia
janogarcia / wp_the_filter_context.php
Last active August 29, 2015 14:02
WordPress the_title filter context
<?php
// Answer for https://twitter.com/david_bonilla/status/480982446641778688
// Tested: using in_the_loop() conditional
add_filter('the_title', 'my_the_title');
function my_the_title($title) {
if (in_the_loop())
@janogarcia
janogarcia / css_class_groups_combinations.md
Last active August 29, 2015 14:16
CSS Class Groups Combinations

Colors = {red, yellow, green, ..., n1}
Sizes = {small, medium, big, ..., n2}
Shapes = {round, soft, square, ..., n3}
Fills = {hollow, solid, gradient, ..., n4}

Cómo obtener todas las posibles combinaciones para las siguientes condiciones:

  • El tamaño mínimo de las combinaciones es 1 y el tamaño máximo n es igual al número total de grupos: mínimo 1 {red}, máximo 4 {red, small, round, hollow}
  • No se pueden repetir los elementos: {red, red} no es una combinación válida
  • Sólo puede haber un elemento de cada grupo: {red, yellow} no sería una combinación válida
//
// While TinyMCE can strip out <script> tags,
// it does not remove inline JS event handlers.
//
// Example: onmouseover, onclick, etc.
//
// This should be included at the bottom of a page,
// contained inside an <iframe> to sandbox user-created
// content. The reason it is contained in an <iframe>
// is to prevent user-created CSS from affecting
@janogarcia
janogarcia / php_string_slice.php
Created December 16, 2010 09:03
PHP port of JavaScript String slice() method
<?php
/**
* PHP port of JavaScript String slice() method
*
* @param string $str
* @param int $start
* @param int $end (optional)
*/
function str_slice($str, $start, $end = FALSE)
{
@janogarcia
janogarcia / bootstrap_translucent_ie.less
Created September 30, 2011 09:54
Translucent background colors in IE for Twitter Bootstrap
// Extension to Twitter Bootstrap's mixin.less that adds support for translucent background colors in IE6-IE9 (deprecated as of IE9)
#translucent {
.background(@color: @white, @alpha: 1) {
// http://css3please.com/
// http://msdn.microsoft.com/en-us/library/ms532997(v=vs.85).aspx
background-color: transparent;
background-color: hsla(hue(@color), saturation(@color), lightness(@color), @alpha);
// http://stackoverflow.com/questions/2877322/convert-opacity-to-hex-in-javascript
// http://robertnyman.com/2010/01/11/css-background-transparency-without-affecting-child-elements-through-rgba-and-filters/
@janogarcia
janogarcia / MY_url_helper.php
Created January 9, 2012 12:54
url_title_i18n(): multilanguage version of CodeIgniter url_title() fucntion. #i18n #internationalization #language
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Create URL Title with support for accented characters
*
* Takes a "title" string as input and creates a
* human-friendly URL string with either a dash
* or an underscore as the word separator.
*
* All accented characters get transliterated
@janogarcia
janogarcia / riloadr_minimal.html
Created April 17, 2012 13:19
Riloadr - Minimal example
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="0">
<meta name="viewport" content="width=device-width">
<script type="text/javascript" src="riloadr.min.js"></script>
@janogarcia
janogarcia / MY_Lang.php
Created June 13, 2012 08:32
CodeIgniter 2.1.0 Mutilingual
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
// Adds support for language code in the first segment of the URI.
// It negotiates the language if no language is found in the URI.
// Negotiation priority: URI language code segment > Cookie ($_COOKIE) > User agent ($_SERVER['HTTP_ACCEPT_LANGUAGE']) > Fallback (Configuration)
class MY_Lang extends CI_Lang {
/**
* Config class
@janogarcia
janogarcia / triggers.sql
Created October 18, 2012 15:04
MySQL Log/History Triggers for Audit Trail
DELIMITER //
# Campaign modified timestamps: modified_description, modified_where, modified_conditions, modified_includes
CREATE TRIGGER before_campaigns_update BEFORE UPDATE ON campaigns
FOR EACH ROW
BEGIN
IF (NEW.description <> OLD.description) OR (NEW.description IS NOT NULL AND OLD.description IS NULL) OR (NEW.description IS NULL AND OLD.description IS NOT NULL)
OR (NEW.infolink_text <> OLD.infolink_text) OR (NEW.infolink_text IS NOT NULL AND OLD.infolink_text IS NULL) OR (NEW.infolink_text IS NULL AND OLD.infolink_text IS NOT NULL)
OR (NEW.infolink_url <> OLD.infolink_url) OR (NEW.infolink_url IS NOT NULL AND OLD.infolink_url IS NULL) OR (NEW.infolink_url IS NULL AND OLD.infolink_url IS NOT NULL)
@janogarcia
janogarcia / paymill_cc_validation.md
Created December 7, 2012 11:47
Paymill Credit Card Validation

Paymill ideal scenario (for our webapp)

  1. A user goes to the Profile area of my webapp.
  2. The user then selects the tab Payment.
  3. A form for collecting credit card data is shown in the user's Profile > Payment area.

The Profile > Payment form doesn't involve any transaction, it is just to "save" their credit card data (on Paymill servers, not ours) for later use, on future purchases on our webapp.

That way the user doesn't need to re-enter over and over his credit card deatils each time he wants to make a purchase, smoothing as much as possible the checkout process.