Skip to content

Instantly share code, notes, and snippets.

View fjaguero's full-sized avatar
🏠
Working from home

Fernando Agüero fjaguero

🏠
Working from home
View GitHub Profile
@fjaguero
fjaguero / numberWithThousands.js
Created October 11, 2013 09:28
JS Regex: Adds thousands separator to a number.
// Adds the thousands separator
function numberWithThousands(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
}
@fjaguero
fjaguero / zendesk_trigger_search.py
Created July 22, 2025 12:45
Zendesk Trigger Search Script
"""
Zendesk Trigger Search Script
SETUP INSTRUCTIONS:
1. Make sure you have Python 3.x installed
2. Create a virtual environment (recommended):
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
3. Install required dependencies:
pip install requests
@fjaguero
fjaguero / opengraph-wordpress.php
Created October 17, 2012 08:32
Add Facebook Open Graph Meta Data to Wordpress
//Adding the Open Graph in the Language Attributes - functions.php
function add_opengraph_doctype( $output ) {
return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"';
}
add_filter('language_attributes', 'add_opengraph_doctype');
//Lets add Open Graph Meta Info
function insert_fb_in_head() {
@fjaguero
fjaguero / wp_alt_title_thumb.php
Created October 9, 2012 11:17
Wordpress: Get ALT and TITLE for the post thumbnail
<?php if ( has_post_thumbnail() ) :?>
<a href="<?php the_permalink() ?>" class="thumb"><?php the_post_thumbnail('thumbnail', array(
'alt' => trim(strip_tags( $post->post_title )),
'title' => trim(strip_tags( $post->post_title )),
)); ?></a>
<?php endif; ?>
@fjaguero
fjaguero / sql-prestashop-products.sql
Created February 26, 2013 10:21
Prestashop: SQL All Products
SELECT p.id_product, p.active, pl.name, GROUP_CONCAT(DISTINCT(cl.name) SEPARATOR ",") as categories, p.price, p.id_tax_rules_group, p.wholesale_price, p.reference, p.supplier_reference, p.id_supplier, p.id_manufacturer, p.upc, p.ecotax, p.weight, p.quantity, pl.description_short, pl.description, pl.meta_title, pl.meta_keywords, pl.meta_description, pl.link_rewrite, pl.available_now, pl.available_later, p.available_for_order, p.date_add, p.show_price, p.online_only, p.condition, p.id_shop_default
FROM ps_product p
LEFT JOIN ps_product_lang pl ON (p.id_product = pl.id_product)
LEFT JOIN ps_category_product cp ON (p.id_product = cp.id_product)
LEFT JOIN ps_category_lang cl ON (cp.id_category = cl.id_category)
LEFT JOIN ps_category c ON (cp.id_category = c.id_category)
LEFT JOIN ps_product_tag pt ON (p.id_product = pt.id_product)
WHERE pl.id_lang = 1
AND cl.id_lang = 1
AND p.id_shop_default = 1
@fjaguero
fjaguero / wp-no-category-base.php
Created April 9, 2013 16:30
Wordpress: No Category Base
<?php /*
WP No Category Base
*/
// Refresh rules on activation/deactivation/category changes
register_activation_hook(__FILE__, 'no_category_base_refresh_rules');
add_action('created_category', 'no_category_base_refresh_rules');
add_action('edited_category', 'no_category_base_refresh_rules');
add_action('delete_category', 'no_category_base_refresh_rules');
function no_category_base_refresh_rules() {
@fjaguero
fjaguero / smarty-prestashop-feature.tpl
Created December 18, 2012 17:05
Smarty - Prestashop: Show specific product feature
{foreach from=$features item=feature}
{if $feature.id_feature = 1}
<tr>
<td>{$feature.value|escape:'htmlall':'UTF-8'}</td>
<td>{$feature.id|escape:'htmlall':'UTF-8'}</td>
</tr>
{/if}
{/foreach}
@fjaguero
fjaguero / content.js
Created July 14, 2017 08:01
Content Script
$(document).ready(function() {
// Select the target node (tweet modal)
var target = $('.PermalinkOverlay-modal').get(0);
// Create an observer instance
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
// Get the Twitter modal window replies count
var loneTweetsCount = $('.PermalinkOverlay-body .ThreadedConversation--loneTweet .tweet').length
@fjaguero
fjaguero / background.js
Created July 14, 2017 08:03
Background
// Listen to content.js events
chrome.extension.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.count || request.count === 0) {
chrome.browserAction.setBadgeText({'text': request.count.toString()})
}
}
);
@fjaguero
fjaguero / simpleObserver.js
Created July 14, 2017 07:51
Simple observer
// select the target node
var target = document.querySelector('#some-id');
// create an observer instance
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
console.log(mutation.type);
});
});