Skip to main content

Count PDF pages with php

function getNumPagesInPDF($PDFPath = NULL)
 $stream = fopen($PDFPath, "r");
 $PDFContent = fread ($stream, filesize($PDFPath));

ORDER BY Flexible

Soooo nice:

SELECT * FROM `menu` WHERE weight != 0 ORDER BY (CASE type WHEN 118 THEN 2 WHEN 54 THEN 4 END) DESC

SCP syntax

Useful to copy directories from one server to another:

cd into the dir you want to have your data

scp -prq username@ .

Batch replace text in big files

For example: Change Collation in a big database dump.

cat dumpname | sed s/CHARSET=utf8/CHARSET=utf8\ COLLATE=utf8_unicode_ci/ > neuer_dumpname

Batch resize images on Ubuntu

  • Install imagemagick
  • Create newdir and copy images to be resized into it
  • cd into newdir

mogrify -format jpg -resize "800x500>" *

Extract parts of Mysql dumps

nawk '/CREATE DATABASE \/\*\!32312 IF NOT EXISTS\*\/ \`%DB-NAME%\`/,$0 ~ /CREATE DATABASE/ && $0 !~ /%DB-NAME%/' DUMPFILE > DUMP_DB

Subscribe to