NOTAS

junio 21, 2016 § Deja un comentario

Helper Notes to assist the work day

##
# Cache control from Apache: Expires Header + Removal of Etag
#

<FilesMatch “\.(ico|png|gif|js|css|jpg|jpeg|swf|pdf|flv)”>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault “access plus 30 days”
</IfModule>

# ETag
<IfModule mod_headers.c>
FileETag MTime Size
Header unset Last-Modified
Header set Cache-Control: max-age=604800
</IfModule>
</FilesMatch>

##
# Cadena de ejemplo para arracar MySQL Proxy analizando las consultas de una aplicacion
#
“C:\Program Files\MySQL\MySQL Proxy 0.8.5\bin\mysql-proxy” –proxy-lua-script=”C:\Users\jvelasco\Documents\development\CODE\LUA-Scripts\tutorial-basic.lua” –proxy-backend-addresses=127.0.0.1:3306 –proxy-address=mytesting.localhost:4040

##
# Referencia para aceptar conexiones externas en un servidor MySQL
#
http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html

##
# Referencia para conectar a un Remote Desktop con las credenciales de la maquina local
#
http://superuser.com/questions/584876/how-do-i-use-my-current-credentials-with-remote-desktop

##
# Herramientas diagnostico para dominios
#
http://whatismyipaddress.com/

##
# Añadir binding de un puerto a un dominio existente
#
C:\Windows\System32\inetsrv\appcmd set site /site.name:”autologin-internal” /+bindings.[protocol=’https’,bindingInformation=’*:443:ntlmlogin-internal.obs.tv’]

##
# Deshabilitar Comprobacion de Foreign Keys MYSQL
#
SET foreign_key_checks = 0;
>> sentence we don’t want’t to check constraints
SET foreign_key_checks = 1;

##
# Examine error details related to Foreign Keys
#
SHOW ENGINE INNODB STATUS

##
# Procedure to remove all tables from a given DB
#
DROP PROCEDURE IF EXISTS drop_all_tables_from_specified_database;

DELIMITER $$
CREATE PROCEDURE drop_all_tables_from_specified_database(IN dbname CHAR(50))
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE tblname CHAR(50);
DECLARE cur1 CURSOR FOR SELECT table_name FROM information_schema.tables WHERE table_schema = dbname COLLATE utf8_general_ci;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

SET foreign_key_checks = 0;

OPEN cur1;
read_loop: LOOP
FETCH cur1 INTO tblname;
IF done THEN
LEAVE read_loop;
END IF;
SET @database_name = dbname;
SET @table_name = tblname;
SET @sql_text = CONCAT(‘DROP TABLE ‘, @database_name, ‘.’ , @table_name, ‘;’);
PREPARE stmt FROM @sql_text;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END LOOP;
CLOSE cur1;

SET foreign_key_checks = 1;

END$$
DELIMITER ;

CALL drop_all_tables_from_specified_database(‘tebascms’);

DROP PROCEDURE drop_all_tables_from_specified_database;

##
# Fix git fast-forward issues with git
#
git pull –rebase origin master
git push origin master

##
# Force Git to overwrite local files on pull
#
git fetch –all
git reset –hard origin/master

##
# To stop tracking a file you need to remove it from the index. This can be achieved with this command.
#
git rm –cached <file>
git reset –hard origin/master

##
# To rollback to a specific commit:
#
git reset –hard <commit_sha>

##
# Checkout a previus commit
#
git checkout [revision] .

##
# Useful options for manage git files
#
git add .                           => Add all (tracked and modified)/new files in the working tree.
git add -u                          => Add all modified/removed files which are tracked.
git add -A                          => Add all (tracked and modified)/(tracked and removed)/new files in the working tree.
git commit -a -m “commit message”   => Add and commit modified/removed files which are tracked.
git ls-files –deleted              => Show all files with the mark delelted

##
# Show results after executing an engine operation
#  – useful to debug FK problems
#
SHOW ENGINE INNODB STATUS

##
# Executes a PHP page asynchronously so the current page does not have to wait for it to finish running.
#
<?php
$params[‘my_param’] = $a_value;
post_async(‘http:://localhost/batch/myjob.php’, $params);
function post_async($url, array $params)
{
foreach ($params as $key => &$val) {
if (is_array($val)) $val = implode(‘,’, $val);
$post_params[] = $key.’=’.urlencode($val);
}
$post_string = implode(‘&’, $post_params);

$parts=parse_url($url);

$fp = fsockopen($parts[‘host’],
isset($parts[‘port’])?$parts[‘port’]:80,
$errno, $errstr, 30);

$out = “POST “.$parts[‘path’].” HTTP/1.1\r\n”;
$out.= “Host: “.$parts[‘host’].”\r\n”;
$out.= “Content-Type: application/x-www-form-urlencoded\r\n”;
$out.= “Content-Length: “.strlen($post_string).”\r\n”;
$out.= “Connection: Close\r\n\r\n”;
if (isset($post_string)) $out.= $post_string;

fwrite($fp, $out);
fclose($fp);
}

##
# Sublime Shortcuts to symbol inspection
#
Jump to definition = Alt+Click
Jump to definition = Control+Windows+Alt+Up
Go back = Control+Windows+Alt+Left
Manual Code Intelligence = Control+Shift+space

##
# Get the hostname from an IP inside a network
#
NBTSTAT -A 10.10.10.10

##
# Increase limits to FIX MySQL Server has gone away (my.ini)
#
wait_timeout        large enough.
max_allowed_packet  set max_allowed_packet = 128M.

Anuncios

¿Dónde estoy?

Actualmente estás viendo los archivos para junio, 2016 en J. Manuel Velasco Weblog.