Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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