# This example does an AJAX lookup and is in CoffeeScript
$('.typeahead').typeahead(
# source can be a function
source: (typeahead, query) ->
# this function receives the typeahead object and the query string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
__author__ = 'efrenfuentes' | |
MONEDA_SINGULAR = 'bolivar' | |
MONEDA_PLURAL = 'bolivares' | |
CENTIMOS_SINGULAR = 'centimo' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias log-apache='tail -f /var/log/apache2/error.log' | |
alias python-clean='find . -name "*.py[c|o]" -exec rm -rvf {} \;' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from operator import or_ | |
from django.db.models import Q | |
from django.core.exceptions import ImproperlyConfigured | |
class SimpleSearchMixin(object): | |
def search_query(self): | |
return self.request.GET.get('query_search') | |
def get_context_data(self, **kwargs): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add in /override/Tools.php | |
/** | |
* Añade un hook al sistema | |
*/ | |
function addHook($name, $title, $desc, $position=1) { | |
return Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'hook` (`name`, `title`, `description`, `position`) VALUES (\''.$name.'\', \''.$title.'\', \''.$desc.'\', '.$position.')'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Comprueba si es número de teléfono válido: | |
* | |
* ######### | ### ###### | ### ## ## ## | |
* | |
* @param $telefono string, número de teléfono a comprobar | |
* | |
* @return true o false | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Comprueba si es un número de postal válido: ##### | |
* | |
* @param $codigo string, código postal a comprobar | |
* | |
* @return true o false | |
*/ | |
static public function isCodigoPostal($codigo) { | |
return preg_match('/^[0-9]{5,5}$/', $codigo); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function addRewriteRule($rules, $comment="", $endcomment="") { | |
if (($htaccess = file_get_contents(_PS_ROOT_DIR_.'/.htaccess')) === FALSE) | |
return FALSE; | |
if (($pos = strrpos($htaccess, "<IfModule mod_rewrite.c>")) === FALSE) | |
return FALSE; | |
if (($pos = strpos($htaccess, "</IfModule>", $pos)) === FALSE) | |
return FALSE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add days to a date. | |
* | |
* @param string $d, date | |
* @param int $ndays, number of days | |
* @param string $format, format date (@see: http://php.net/manual/en/function.date.php) | |
*/ | |
function add_days($ndays, $d, $format="Y-m-d") { | |
$p = $ndays > 1 ? "s" : ""; | |
$nf = strtotime(date($format, strtotime($d)) . " +".$ndays." day". $p); |