Fix Templatic’s Private Lawyer text-being-truncated-on-slider bug

I was having problems with the Coda Slider in the Private Lawyer Wordpress Theme by Templatic. (The slider is called the T Anything Slider widget by the theme.) Text was being truncated even when the text length was less than the number of characters specified on the widget settings.

A small modification to the bm_better_excerpt function in wp-content/themes/PrivateLaweyer/library/functions/custom_functions.php solves the problem.

File: wp-content/themes/PrivateLaweyer/library/functions/custom_functions.php

// Excerpt length
function bm_better_excerpt($length, $ellipsis) {
$text = get_the_content();
// fix weird bug that caused substr to chop
// text even if $length was greater than string length
if (strlen($text) > $length) {
$text = strip_tags($text);
$text = substr($text, 0, $length);
$text = substr($text, 0, strrpos($text, " "));
$text = $text.$ellipsis;
return $text;
php private lawyer theme templatic wordpress wordpress theme

John Carmack on rigorous code analysis

Gamasutra interviews John Carmack, creator of Doom.

One of the humbling things that you find is that, no matter how good of a programmer you are, you write code, and you make stupid mistakes. And I am getting to be a huge proponent of really, really rigorous code analysis, because I have been going through pioneering these things, just squeegeeing through our code base, and every single programmer – from our best to our worst – they all make stupid mistakes, and they are unavoidable.

bugs carmack code analysis debugging

Using TextMate and Python’s virtualenv

TextMate is a great text editor for MacOs. But the default Python bundle does not recognize Python’s virtual environments (virtualenv), which is rather annoying.

No need to modify your Textmate bundle. This can be solved by declaring a project-specific shell variable named TM_PYTHON and assigning your virtualenv’s custom python’s path to it:

  • In TextMate, create a new project for your python program
  • Open the Project Drawer Window (View/Open Project Drawer)
  • Make sure no file is selected in the drawer. Click on the Get-Info icon to open the Project Information Dialog (see picture)
  • Add a variable named TM_PYTHON and assign it your virtualenv python path

(Your virtualenv python path can be obtained by typing which python in a Terminal window after activating your virtualenv environment with workon.)

Creating the TM_PYTHON project-specific shell variable on TextMate

bundles python textmate TM_PYTHON virtualenv virtualenvwrapper

Java Programming 101

Releyendo unos posts antiguos de otro blog, encontré unos apuntes que escribí el 2006 para complementar las clases de Programación Java que dicté en la Facultad de Ingeniería de la Universidad de Piura en Lima. Los vuelvo a publicar por si sirven a otros.

Los apuntes están publicados bajo una licencia Creative Commons Attribution-ShareAlike 2.5. Se pueden crear trabajos derivados, copiar, compartir, etc., mientras se respete esa licencia. Si alguno quiere los archivos originales para modificarlos, se los puedo enviar.

  1. Introducción
  2. Inheritance
  3. Exceptions
  4. io streams
  5. Polymorphism
  6. Interfaces
  7. Listas
  8. Collections
  9. Super-repaso de mitad de curso.
exceptions inheritance Java programming polymorphism