Skip to content

Instantly share code, notes, and snippets.

And what about pgettext and npgettext? They are there in the gettext documentation, but there aren't in PHP. They're very useful if you have the same messages for translation, but in different contexts, so they should be translated separately and probably differently.
Fortunately, there is a simple work-around, which may help:
From the gettext.h header one can find out that pgettext() is only a macro calling dcgettext() internally with properly mangled parameters - msgctxt and msgid are glued together with use of ASCII char 4 [EOT, End Of Text]. The same way they're written in .mo files, so it's possible to refer them this way.
Here's my "emulated" pgettext() function:
<?php
if (!function_exists('pgettext')) {
@pherrymason
pherrymason / select text in a node.js
Created December 15, 2013 09:33
Select text in a node.
function SelectText(element) {
var doc = document;
var text = doc.getElementById(element);
if (doc.body.createTextRange) {
var range = document.body.createTextRange();
range.moveToElementText(text);
range.select();
} else if (window.getSelection) {
var selection = window.getSelection();
var range = document.createRange();
@pherrymason
pherrymason / .git.txt
Created December 15, 2013 16:58
Git config
[core]
filemode = false # Ignore file mode
(function($,sr){
// debouncing function from John Hann
// http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
var debounce = function (func, threshold, execAsap) {
var timeout;
return function debounced () {
var obj = this, args = arguments;
function delayed () {
if (!execAsap)
func.apply(obj, args);
@pherrymason
pherrymason / snowflakes.js
Created December 25, 2013 09:37
Snowflakes with javascript & canvas
(function () {
var COUNT = 300;
var masthead = document.querySelector('.masthead');
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
var width = masthead.clientWidth;
var height = masthead.clientHeight;
var i = 0;
var active = false;
@pherrymason
pherrymason / remove git submodule.md
Created January 14, 2014 16:13
Fully remove Git Submodule
@pherrymason
pherrymason / phpdoc.php
Created February 6, 2014 12:31
PHP DOC tags
/**
* The short description
*
* As many lines of extendend description as you want {@link element} links to an element
* {@link http://www.example.com Example hyperlink inline link} links to a website
* Below this goes the tags to further describe element you are documenting
*
* @param type $varname description
* @return type description
* @access public or private
@pherrymason
pherrymason / tarjetas de prueba.md
Last active January 19, 2024 22:24
Tarjetas de prueba. NO SIRVEN para realizar pagos reales. Sólo los desarrolladores sabrán para que sirven.

##4B (Banco pastor, Banco popular, Banco Santander Cental Hispano…):

  • Nº Tarjeta: 40000 Cualquier fecha de caducidad futura y cvv2: 111
  • Nº Tarjeta: 12345 Cualquier fecha de caducidad futura y cvv2: 111

##CECA (BBK, Kutxa,CajaSur, Caja Granada, Caja de guadalajara…):

  • 5540500001000004 Caducidad: AAAA12 (Diciembre del año en curso) CVV2: 989
  • 5020470001370055 Caducidad: AAAA12 (Diciembre del año en curso) CVV2: 989
  • 5020080001000006 Caducidad: AAAA12 (Diciembre del año en curso) CVV2: 989
@pherrymason
pherrymason / Create sections.html
Created March 7, 2014 09:15
Crear secciones en plantillas de Mailchimp
<!-- // Begin Module: Standard Content \\ -->
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign="top">
<div mc:edit="std_content00">
<h2>New Solutions &amp; Updates</h2>
We hope you're having fun in the sun this summer! The Generitech team is excited to announce several powerful new solutions and a few updates to existing products, all available in June! Thanks to our loyal newsletter subscribers for experiencing the difference, month after month.
</div>
</td>
</tr>
@pherrymason
pherrymason / unbind.hoverIntent.js
Created April 11, 2014 11:06
Unbind jQuery HoverIntent
var rawIntent = $.fn.hoverIntent;
$.fn.hoverIntent = function(handlerIn, handlerOut, selector){
var args = arguments;
return this.each(function(){
// If called with empty parameter list, disable hoverIntent
if( typeof handlerIn==='undefined' )
{
// Destroy the time if it is present
if( typeof(this.hoverIntent_t!=='undefined') )