Skip to content

Instantly share code, notes, and snippets.

@slivero
slivero / compress_pdf.sh
Created September 22, 2011 09:38
Compress a pdf file using ghostscript (Should work on any OS)
# Compresses a pdf file
# Compression level can be adjusted by changing -dPDFSETTINGS
# Possible values:
# -dPDFSETTINGS=/screen (screen-view-only quality, 72 dpi images)
# -dPDFSETTINGS=/ebook (low quality, 150 dpi images)
# -dPDFSETTINGS=/printer (high quality, 300 dpi images)
# -dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs)
# -dPDFSETTINGS=/default (almost identical to /screen)
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
@slivero
slivero / join_pdfs.sh
Created September 22, 2011 09:39
Join pdfs on linux using pdftk
pdftk file1.pdf file2.pdf file3.pdf cat output newfile.pdf
@slivero
slivero / Cylinderize.sh
Created September 22, 2011 12:40
Cylinderize an image (Saved here as a backup of original http://www.fmwconcepts.com/imagemagick/cylinderize/index.php)
#!/bin/bash
#
# Developed by Fred Weinhaus 5/1/2009 .......... revised 4/12/2010
#
# USAGE: cylinderize [-m mode] [-r radius] [-l length] [-w wrap] [-f fcolor] [-a angle] [-p pitch] [-n narrow] [-v vpmethod] [-b bgcolor] [-t] infile outfile
# USAGE: cylinderize [-h or -help]
#
# OPTIONS:
#
# -m mode mode of orientation for cylinder axis; options are
@slivero
slivero / dropshadow_modal.css
Created September 22, 2011 12:42
A nice modal box with css dropshadow
.modal {
position: absolute;
top:0;
left:0;
z-index: 2000;
height:300px;
width:400px;
background-color: white;
border-radius:10px;
border: 1px solid rgba(0, 0, 0, 0.3);
@slivero
slivero / jquery.center.js
Created September 22, 2011 13:00
Add centre() function to jquery to center modals
(function($){
$.fn.extend({
center: function () {
return this.each(function() {
var top = ($(window).height() - $(this).outerHeight()) / 2;
var left = ($(window).width() - $(this).outerWidth()) / 2;
$(this).css({position:'absolute', margin:0, top: (top > 0 ? top : 0)+'px', left: (left > 0 ? left : 0)+'px'});
});
}
});
@slivero
slivero / multi-process.php
Created October 7, 2011 14:02
Demonstration of process forking in PHP to speed up image resizing
<?php
/**
* Create a thumbnail image from the specified file
*
* @param int $height output image height
* @param int $width output image width
*/
function create_preview($height, $width)
@slivero
slivero / ssh.sh
Created January 13, 2012 11:40
ssh tunnel for windows remote desktop
ssh -L 13389:<remote desktop server ip>:3389 <remote ssh server>
@slivero
slivero / MY_Exceptions.php
Created April 9, 2012 18:26
JSON error messages for CI 2.0+
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
/**
* Extending the default errors to always give JSON errors
*
* @author Oliver Smith
*
@slivero
slivero / .htaccess
Created May 3, 2012 06:44
Silex .htaccess
Options -MultiViews
RewriteEngine On
#RewriteBase /path/to/app
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
@slivero
slivero / circle.svg
Created May 19, 2012 21:24
Styling the HTML5 Meter Tag Using the Shadow DOM
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.