martes, 21 de noviembre de 2017

Caracteres raros en la consola

Posiblemente, los problemas derivados de un mal uso o mala comprensión del encoding, sea uno de los principales dolores de cabeza para muchos desarrolladores. Es fácil determinar que cuando en una web estamos viendo «sensación» en vez de «sensación», es que pasa algo con el encoding.

¿Cómo solventar este problema en la consola de windows?

Pues simplemente dos pasos:

  1. Establecer como tipo de letra en las propiedades del intérprete de comandos (el conocido "Símbolo de sistema de Windows") "Consolas" o "Lucida Console"
  2. Cambiar la "página de códigos" utilizada empleando el comando chcp. En concreto, para utilizar la codificación de caracteres CP-1252 hay que teclear: chcp 1252. O si tu proyecto utiliza UTF-8, ejecutar chcp 65001

jueves, 7 de septiembre de 2017

¿Qué Web soporta desde tu dispositivo?

¿Puedo confiar en las funciones de la Plataforma Web para crear mi aplicación? Una visión general de las APIs HTML5 de integración de dispositivos Enlace web:

lunes, 7 de agosto de 2017

Uso de temas de Bootswatch para Jhipster

Requiere una versión mayor a la 4 de JHipster y cuya definición sea AngularJS

Para tener temas Bootswatch en lugar del tema por defecto sólo tiene que sustituir el css bootstrap con el css del tema bootswatch. Sin embargo, si desea un conmutador de tema fresco para cambiar entre los temas de Bootswatch dinámicamente, a continuación, siga esta sugerencia.




Nota: reemplace ‘pscApp’ con el nombre generado de su aplicación.

Agrege los siguientes ficheros:

Controlador


Agrega el siguiente controlador como bootswatch.controller.js bajo la ruta webapp/app/components/bootswatch
(function() {
 'use strict';
 
    angular
        .module('pscApp')
        .controller('BootswatchController', BootswatchController);

    BootswatchController.$inject = ['$scope', 'BootSwatchService'];

 function BootswatchController ($scope, BootSwatchService) {

   /*Get the list of availabel bootswatch themes*/
   BootSwatchService.get().then(function(themes) {
    $scope.themes = themes.themes;
    $scope.themes.unshift({name:'Default',css:''});
    //$scope.themes.push({name:'Default',css:''});
   });
   
 }

})();

Servicio


Agrega el siguiente servicio como bootswatch.service.js bajo la ruta webapp/app/components/bootswatch
(function() {
 'use strict';
 
    angular
        .module('pscApp')
        .factory('BootSwatchService', BootSwatchService);

    BootSwatchService.$inject = ['$http'];

 function BootSwatchService ($http) {
  return {
   get: function() {
    
    return $.getJSON("https://bootswatch.com/api/3.json", function (data) {
      return data.themes;
    } );

   }
  };
 }
 
})();

Directiva


Agrega la siguiente directiva como bootswatch.directive.js bajo la ruta webapp/app/components/bootswatch
(function() {
 'use strict';
 
    angular
        .module('pscApp')
        .directive('jhSwitchTheme', jhSwitchTheme);

    function jhSwitchTheme () {
  /*Directive binds to anchor to update the bootswatch theme selected*/
  return {
   restrict: 'A',
   scope: {
    theme : '=jhSwitchTheme'
   },
   link: function (scope, element, attrs) {
    var currentTheme = $("#bootswatch-css").attr('title');
    if(scope.theme.name === currentTheme){
     element.parent().addClass("active");
    }

    element.on('click',function(){
     $("#bootswatch-css").attr("href", scope.theme.css);
     $(".theme-link").removeClass("active");
     element.parent().addClass("active");
    });
   }
  };
 }

})();

En el index.html:


Agregue lo siguiente al archivo index.html después de la tarea de construcción CSS vendor.css para que éstas no se minifiquen y compacten por tarea de compilación.

Añada en el header
   
    
 ...
    
    
 
 
    
    
    
    

Añada lo siguiente en el pie de página
     


Agrege los siguientes script tags en el fichero index.html manualmente. Si ‘gulp inject’ falla, recibirá errores de angular
    
 
 
 

jueves, 12 de enero de 2017

Agregar "Abrir con Notepad++" para el menú contextual del Explorador de Windows

Abrimos el cmd ( "Windows + R" y escribimos "cmd" ) con permiso de administrador  y copamos el siguiente código. Pulsamos intro y, "Listo".

Nota: Revisa el directorio (notepadPath) donde tienes instalado el programa notepad++. En mi caso particular, notepad se encuentra en la siguiente ruta C:\Program Files (x86)\npp.7.2\ 
 
@echo off
SET notepadPath=C:\Program Files (x86)\npp.7.2\notepad++.exe
 
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with notepad++"         /t REG_SZ /v "" /d "Open with notepad++"   /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with notepad++"         /t REG_EXPAND_SZ /v "Icon" /d "%notepadPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with notepad++\command" /t REG_SZ /v "" /d "%notepadPath% %1" /f 

rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with notepad++" /t REG_SZ /v "" /d "Open with notepad++" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with notepad++" /t REG_EXPAND_SZ /v "Icon" /d "%notepadPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with notepad++\command" /t REG_SZ /v "" /d "%notepadPath% %1" /f
pause

A modo de ejemplo vamos a hacerlo lo mismo para Brackets, para ver que es aplicable para todos los programas.

@echo off
SET st2Path=C:\Program Files (x86)\Brackets\Brackets.exe
 
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Brackets"         /t REG_SZ /v "" /d "Open with Brackets"   /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Brackets"         /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open Brackets\command" /t REG_SZ /v "" /d "%st2Path% \"%1\"" /f 

rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Brackets" /t REG_SZ /v "" /d "Open with Brackets" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Brackets" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Brackets\command" /t REG_SZ /v "" /d "%st2Path% \"%1\"" /f
pause