Skip to content

Instantly share code, notes, and snippets.

View janogarcia's full-sized avatar

Jano Garcia janogarcia

View GitHub Profile
@janogarcia
janogarcia / css_coding_guidelines.md
Last active February 13, 2022 03:13
CSS Coding Guidelines
@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 / http_build_url.php
Last active December 14, 2015 18:09
CodeIgniter helper: http_build_url() PHP implementation
<?php
/**
* Takes an associative array in the layout of parse_url, and constructs a URL from it
*
* see http://www.php.net/manual/en/function.http-build-url.php#96335
*
* @param mixed (Part(s) of) an URL in form of a string or associative array like parse_url() returns
* @param mixed Same as the first argument
* @param int A bitmask of binary or'ed HTTP_URL constants (Optional)HTTP_URL_REPLACE is the default
@janogarcia
janogarcia / php_bug_unset_object_property_by_reference.php
Last active December 14, 2015 01:29
PHP Bug: An object is automatically created if an unset object with a property is passed by reference. Inconsistent warnings depending on the variable type.
<?php
// Possible PHP Bug:
// An object is automatically created if an unset object with a property is passed by reference
// Inconsistent Warnings depending on the variable type
// Live test http://codepad.viper-7.com/ueZkz4
// Possibly related PHP bug https://bugs.php.net/bug.php?id=52237
<?php
class MY_Model extends CI_Model {
// Form validation rules
protected $rules = array();
// Sets form validation rules
protected function set_rules($field_names)
{
@janogarcia
janogarcia / php_logical_operators.php
Created December 12, 2012 15:32
PHP Logical operators: The difference between OR vs ||, AND vs && explained. Key concepts: Logical operators precendence. Logical operators short-circuit evalutation.
<?php
// PHP Logical operators: The difference between OR vs ||, AND vs &&
// Key concept #1: "||" and "&&" have greater precedence than "=", "OR", "AND"
// http://php.net/manual/en/language.operators.precedence.php
// Key concept #2: PHP logical operators are short-circuit
// http://en.wikipedia.org/wiki/Short-circuit_evaluation
// http://php.net/manual/en/language.operators.logical.php
@janogarcia
janogarcia / paymill_vs_paypal.md
Created December 10, 2012 10:09
Procesando tarjetas de crédito en tu webapp: Paymill VS PayPal

Procesando tarjetas de crédito en tu webapp: Paymill VS PayPal

TL;DR PayPal fatal. Paymill molamil.

Integración del proceso de checkout

PayPal no ofrece en España un método de pago que se integre por completo con tu webapp. La integración más básica Pago estándar consiste básicamente en redirigirte a PayPal e introducir ahí los datos de tu tarjeta. Es decir, la clásica página estándar de checkout de PayPal, con su típico look & feel.

La alternativa algo más avanzada, Pasarela integral, permite que en esa página externa de PayPal se pueda personalizar el logo... y algún que otro detalle (según PayPal "hasta 21 elementos gráficos").

@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.

@janogarcia
janogarcia / gearman_admin.md
Created November 26, 2012 09:05
Gearman Server Administration (telnet, PHP)

Telnet

The Gearman job server supports a text-based protocol to pull information and run some administrative tasks. The following commands are supported:

  • workers
  • status
  • maxqueue
  • shutdown
  • version