Skip to content

Instantly share code, notes, and snippets.

View viezel's full-sized avatar

Mads Møller Schrøder viezel

View GitHub Profile

This can reduce files to ~15% of their size (2.3M to 345K, in one case) with no obvious degradation of quality.

ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Other options for PDFSETTINGS:

  • /screen selects low-resolution output similar to the Acrobat Distiller "Screen Optimized" setting.
  • /ebook selects medium-resolution output similar to the Acrobat Distiller "eBook" setting.
  • /printer selects output similar to the Acrobat Distiller "Print Optimized" setting.
  • /prepress selects output similar to Acrobat Distiller "Prepress Optimized" setting.
@viezel
viezel / ClearBeanstalkdQueueCommand.php
Last active August 29, 2015 14:27 — forked from lukaswhite/ClearBeanstalkdQueueCommand.php
Clear a Beanstalkd Queue in Laravel
<?php
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class ClearBeanstalkdQueueCommand extends Command {
/**
@viezel
viezel / imagick-3.4.0-PHP7-forge.sh
Created June 22, 2016 16:18 — forked from pascalbaljet/imagick-3.4.0-PHP7-forge.sh
Install Imagick 3.4.0 on PHP 7.0 server (Laravel Forge)
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
apt-get install pkg-config libmagickwand-dev -y
cd /tmp
wget https://pecl.php.net/get/imagick-3.4.0.tgz
tar xvzf imagick-3.4.0.tgz
@viezel
viezel / import.php
Last active August 29, 2024 08:11
Import test using Laravel-Excel
<?php
public function import(Request $request)
{
ini_set('max_execution_time', 300);
info("\n\n------------------ NEW ---------------------- ");
info("Start import: " . (memory_get_usage()/1024/1024) . " MB");
$before = microtime(true);
// use chunk to import the products from CSV
@viezel
viezel / bash.sh
Last active November 18, 2021 17:10
ghostscript - pdf conversion
## using Ghostscript, poppler-utils & qpdf
# gs docs: https://ghostscript.com/doc/9.18/Use.htm#Other_parameters
# poppler: https://freedesktop.org/wiki/Software/poppler/
# qpdf docs: http://qpdf.sourceforge.net/files/qpdf-manual.html
# optimize pdf to use use CropBox, remove dublicate image refs, compress
gs -sDEVICE=pdfwrite -dUseCropBox -dPDFSETTINGS=/ebook -dNOPAUSE -dBATCH -dDetectDuplicateImages=true -sOutputFile=test-out.pdf test.pdf
@viezel
viezel / README.md
Last active July 30, 2018 13:21 — forked from manuelselbach/README.md
xdebug docker on macOS with PhpStorm

Use xdebug with docker on macOS and PhpStorm

To use xdebug with macOS and docker is quite, let´s call it tricky ;)

The following steps need to be proceed to get it working:

  1. use the config from the xdebug.ini wihtin your docker web container. Important: set remote_connect_back to off
  2. set up an alias for your local interface (lo)

To bring up the alias at startup, you can either (sudo may be needed here):

@viezel
viezel / composer.json
Created April 30, 2019 12:24
Gitlab Project Migrations
{
"name": "napp/gitlab-migration",
"require": {
"php-http/guzzle6-adapter": "^1.0",
"m4tthumphrey/php-gitlab-api": "^9.13"
}
}
@viezel
viezel / bug.md
Last active January 8, 2020 13:30
Possible bug: Config persists between queue jobs ?

Possible bug: Config persists between queue jobs ?

I think i found a bug in handling of queue jobs in Laravel. If I run laravel queue jobs with config cached in laravel, then runtime configs persists between jobs.

Expected result: Second job does not know of runtime config.

How to reproduce

@viezel
viezel / databases sizes.sql
Created January 29, 2020 12:21
Get sizes of all databases in server
SELECT
table_schema 'Database Name',
SUM(data_length + index_length) 'Size in Bytes',
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) 'Size in MiB'
FROM information_schema.tables
GROUP BY table_schema;
@viezel
viezel / log query
Created April 22, 2020 08:05
Laravel Vapor - Cloudwatch insights logs
fields @timestamp, @message
# Lambda
| filter @message not like "START RequestId"
| filter @message not like "END RequestId"
| filter @message not like "REPORT RequestId"
# FPM
| filter @message not like "NOTICE: ready to handle connections"
| filter @message not like "NOTICE: fpm is running"