Skip to content

Instantly share code, notes, and snippets.

View pollin14's full-sized avatar

Victor Aguilar pollin14

  • Medtrainer
  • Mexico D.F.
View GitHub Profile
@pollin14
pollin14 / nginx-vhost.conf
Created April 25, 2018 16:53 — forked from tjstein/nginx-vhost.conf
nginx vhost config for WordPress + PHP-FPM
upstream php-fpm {
server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name www.example.com;
rewrite ^ http://example.com$request_uri?;
}
@pollin14
pollin14 / cli-xdebug.sh
Last active July 27, 2017 17:43
Command to debug a php script with PHPStorm
## Execute a command with the current environment extended
##
## The PHP_IDE_CONFIG set the serverName with the value defined in PHPStorm's server seccion. With this value PHPStorm
## will not create a new server each time that lisen a new connection. The value does not affect the debug or listening
## of PHPStorm so, you can omite it securely.
##
## The second variable XDEBUG_CONFIG must be have the same value that its equivalent value in *-xdebug.ini.
##
## Set the remote ip in *-xdebug.ini is also required.
env PHP_IDE_CONFIG="serverName=vagrant" XDEBUG_CONFIG="idekey=vagrant" php shell/indexer.php
@pollin14
pollin14 / RIBPS.sql
Created July 25, 2017 19:57
Query to return the size of the tables in mysql
/**
Recommended InnoDB Buffer Pool Size (RIBPS) with additional 60% (1.6 rate). The result's units is giga bytes.
Source: https://dba.stackexchange.com/questions/27328/how-large-should-be-mysql-innodb-buffer-pool-size
*/
SELECT CEILING(Total_InnoDB_Bytes*1.6/POWER(1024,3)) RIBPS FROM
(SELECT SUM(data_length+index_length) Total_InnoDB_Bytes
FROM information_schema.tables WHERE engine='InnoDB') A;
@pollin14
pollin14 / select-relaciones-entre-rules-products.sql
Last active July 20, 2017 15:01
Dos sentencias SELECT para obtener la relación entre reglas y productos en Magento
SELECT
2,
`cg`.`customer_group_id`,
`p`.`entity_id`,
189796,
1484006400,
1514764799,
'by_percent',
50,
0,
@pollin14
pollin14 / reindex-anchor-category.sql
Created July 13, 2017 15:53
Consulta que Magento realiza para re-indexar los productos en la categorías anchor
## _reindexNonAnchorCategories
## This method is not the problem
##
## Results
## Range self::RANGE_CATEGORY_STEP = 500
## Take the entities which id is between 500*n 500*(n+1)
## Benchmark completed 4m 21s 77ms X 32 queries = 2h 19m 12s = 2h
INSERT IGNORE INTO `catalog_category_product_index_tmp` (`category_id`, `product_id`, `position`, `is_parent`, `store_id`, `visibility`)
SELECT
`cc`.`entity_id` AS `category_id`,
@pollin14
pollin14 / reindex-non-anchor-category.sql
Created July 13, 2017 15:32
Consulta que Magento realiza para re-indexar los productos en la categorías non-anchor
## _reindexNonAnchorCategories
## This method is not the problem
##
## Results
## Range self::RANGE_CATEGORY_STEP = 500
## Take the entities which id is between 500*n 500*(n+1)
## Benchmark 13687 rows affected in 3s 942ms X 32 queries ~ 96s
INSERT INTO `catalog_category_product_index_tmp` (`category_id`, `product_id`, `position`, `is_parent`, `store_id`, `visibility`)
SELECT
`cc`.`entity_id` AS `category_id`,
@pollin14
pollin14 / clean-blast.py
Last active April 22, 2017 22:42
Read a FASTA format and remove all except the ID and the sequence and write a new FASTA file
## Tested with python Python 2.7.12
# Instructions
#
# 1. Put the fasta file in the same directory of this file with the name
# blast.fasta.
# 2. Run the script with the origin file name and the destination file name
#
# Example: python clean_blast.py file1.fasta my_file.fasta
@pollin14
pollin14 / php-cs-fixer-pre-commit.php
Last active September 25, 2015 21:31 — forked from mardix/php-cs-fixer-pre-commit.php
A pre-commit hook to check syntax errors and PSR2
#!/usr/bin/php
<?php
/**
* .git/hooks/pre-commit
*
* This pre-commit hooks will check for PHP error (lint), and make sure the code
* is PSR compliant.
*
* Dependecy: PHP-CS-Fixer (https://github.com/fabpot/PHP-CS-Fixer)
*
/*
* Widget 1.0
* Author: Wender Lima
*/
!function(e,l,id,s,r,d){
var c=null,
v=null,
jQ=null,
h=e.getElementsByTagName('head')[0],
w=e.getElementById(id);
@pollin14
pollin14 / sublime-packages.yaml
Last active August 29, 2015 14:11
sublime packages
packages :
- jshint # requires the nodejs package with the same name.
- SideBarEnhancement
- TrailingSpaces
- DocBlockr
- SublimeLinter
- SublimeLinter-jshint
- Emmet