Skip to content

Instantly share code, notes, and snippets.

@jgdoncel
jgdoncel / new_gist_file.php
Created October 18, 2013 09:07
Mostrar errores detallados
error_reporting(E_ALL);
ini_set('display_errors', '1');
@jgdoncel
jgdoncel / .htaccess
Created October 18, 2013 10:30
Configurar Charset por defecto en .htaccess
AddDefaultCharset utf-8
@jgdoncel
jgdoncel / imagemagick.bat
Created October 22, 2013 08:51
Imagemagick - Comandos útiles
REM LISTA DE FORMATOS
REM ---------------------------
convert -list format
REM DE UN FORMATO A OTRO
REM ---------------------------
convert input output
REM REDIMENSIONAR
REM ---------------------------
@jgdoncel
jgdoncel / pdftk.bat
Created October 22, 2013 08:55
PDFTK - Comandos útiles
REM Para unir dos documentos diferentes podemos ejecutar lo siguiente desde la consola:
pdftk archivo1.pdf archivo2.pdf cat output salida.pdf
REM Tambien podemos unirlos utilizando etiquetas:
pdftk A=archivo1.pdf B=archivo2.pdf cat A B output salida.pdf
REM Y por supuesto podemos usar comodines:
pdftk *.pdf cat output salida.pdf
REM Para separar páginas de varios documentos y crear un documento nuevo con estas hacemos lo siguiente:
@jgdoncel
jgdoncel / ghostscript.bat
Created October 22, 2013 08:56
GhostScript - Comandos útiles
REM PS TO PDF
gswin32c -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=test.pdf -dBATCH -dNOPAUSE test.ps
REM PDF TO PNG
gswin32c -sDEVICE=png16m -sOutputFile=salida.png -r300 entrada.pdf
REM Devices disponibles
gswin32c -h
gswin32c -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies=1 -sDEVICE=ljet4 -sOutputFile="\\spool\\\Server_Name\Printer_name" "C:\test.pdf"
@jgdoncel
jgdoncel / sendFtp.cs
Created October 23, 2013 09:58
Enviar un fichero por FTP usando C# para .NET
string ftpServerIP = "ftp.example.com";
string ftpUserName = "username";
string ftpPassword = "password";
string filename = Server.MapPath("example.txt");
FileInfo objFile = new FileInfo(filename);
FtpWebRequest objFTPRequest;
// Create FtpWebRequest object
@jgdoncel
jgdoncel / app.js
Last active December 26, 2015 10:49
Descomponer en RGB un color pasado en hexadecimal.
function hexToRgb (hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}
@jgdoncel
jgdoncel / example.js
Created October 24, 2013 17:20
Three.js - Usar una imagen base 64 como textura From https://github.com/mrdoob/three.js/issues/3430
var image = document.createElement( 'img' );
var texture = new THREE.Texture( image );
image.onload = function() {
texture.needsUpdate = true;
...
};
image.src = 'data:image/png;base64,XXXXX';
$("#<%= txtMultipleName.ClientID %>").autocomplete({
source: function (request, response) {
$.getJSON("AutoComplete.ashx", {
term: extractLast(request.term)
}, response);
},
search: function () {
// custom minLength
var term = extractLast(this.value);
if (term.length < 1) {
@jgdoncel
jgdoncel / ionice.sh
Created November 7, 2013 12:04
Ejemplo de llamada en un CGI perl usando ionice para definir la prioridad del proceso de ejecución. From http://manpages.courier-mta.org/htmlman1/ionice.1.html
# ionice -c 3 -p 89 Sets process with PID 89 as an idle I/O process.
# ionice -c 2 -n 0 bash Runs 'bash' as a best-effort program with highest priority.
# ionice -p 89 91 Prints the class and priority of the processes with PID 89 and 91.
system ("ionice -c 2 -n 7 pdftk $tmp1 $tmp2 output -");