Skip to content

Instantly share code, notes, and snippets.

@Rady
Rady / use-cat-grep-sed-get-all-links-from-webpage
Created January 14, 2022 14:15
use cat, grep, sed extract all links from file
@Rady
Rady / compress-pdf-with-gs.md
Created September 29, 2021 10:26 — forked from drawveloper/compress-pdf-with-gs.md
Compress PDF files with ghostscript

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.
@Rady
Rady / wget-download-urls-pdf-image
Created September 16, 2021 15:06
use wget download all PDF files and images from URLs. sometime need ignore robots.txt.
wget -e robots=off -r -l3 -nc -A pdf,htm,jpg -i all-urls-text-file.txt
// URLs in all-urls-text-file.txt, line by line like:
// http://www.target-site.com/url-1.htm
// http://www.target-site.com/url-2.htm
// http://www.target-site.com/url-3.htm
// ...
@Rady
Rady / gulpfile.js
Last active June 14, 2017 14:47
PHP Server gulpfile.js
// grab all our packages
var gulp = require('gulp');
var php = require('gulp-connect-php');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var autoprefixer = require('gulp-autoprefixer');
var sass = require('gulp-sass');
var htmlmin = require('gulp-htmlmin');
var autoprefixerOptions = {
ffmpeg -i input.mp4 -ss 01:32 -t 00:04 -vf "scale=300:-1" -f gif -r 15 output.gif
@Rady
Rady / php.ini
Created November 11, 2016 03:31
php.ini override upload_max_filesize and post_max_size
upload_max_filesize = 10M
post_max_size = 10M
$article = new stdClass;
$article->text = "{loadposition footer}";
// add more to parameters if needed
$params = new JObject;
// Note JDispatcher is deprecated in favour of JEventDispatcher in Joomla 3.x however still works.
JPluginHelper::importPlugin('content',"loadmodule");
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onContentPrepare', array('', &$article, &$params, 0));
@Rady
Rady / crop_546x366_120x70.sh
Created July 12, 2016 01:18
Use ImageMagick batch resizing and cropping images.
#!/bin/bash
mkdir -p resize thumb
for i in *.jpg; do
convert $i -resize '546x366^' -gravity center -crop '546x366+0+0' -quality 100 resize/$i
convert $i -resize '120x70^' -gravity center -crop '120x70+0+0' -quality 100 thumb/$i
done
#!/usr/bin/env sh
for file in *.f4v ; do ffmpeg -i $file -acodec copy -vcodec copy ${file%}.mp4 ; done

cat download_list.txt | xargs you-get