Skip to content

Instantly share code, notes, and snippets.

Steven Lee witwall

Block or report user

Report or block witwall

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@witwall
witwall / 1 - setting up RVM.sh
Created Apr 6, 2013
RVM and Bundler on Dreamhost, I can access https://gist.github.com/muffinista/3276350, so I copy it from the google cache
View 1 - setting up RVM.sh
#
# Step One - Installing RVM
#
curl -L https://get.rvm.io | bash -s stable --ruby
# Then, install ruby 1.8.7 -- you need to basically match the same version of Ruby as Dreamhost
rvm install ruby-1.8.7-p334
View .htaccess
<IfModule mod_fastcgi.c>
AddHandler fastcgi-script .fcgi
</IfModule>
<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi
</IfModule>
Options +FollowSymLinks +ExecCGI
RewriteEngine On
@witwall
witwall / gist:5334142
Created Apr 8, 2013
Here’s the code to replace images in PDFs, in Java and C#. It will replace the first image in the first page.
View gist:5334142
PdfReader pdf = new PdfReader("in.pdf");
PdfStamper stp = new PdfStamper(pdf, new FileOutputStream("c:\\out.pdf"));
PdfWriter writer = stp.getWriter();
Image img = Image.getInstance("image.png");
PdfDictionary pg = pdf.getPageN(1);
PdfDictionary res =
(PdfDictionary)PdfReader.getPdfObject(pg.get(PdfName.RESOURCES));
PdfDictionary xobj =
(PdfDictionary)PdfReader.getPdfObject(res.get(PdfName.XOBJECT));
if (xobj != null) {
View CropImage.java
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.Transparency;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.PixelGrabber;
@witwall
witwall / deskew.java
Created May 12, 2013
Automatic image deskew in Java http://anydoby.com/jblog/en/java/1990 Those who have to process scans should know how painful it is to manually deskew images. There are several approaches to do this deskewing automatically. The basis of all the methods is to identify lines following the same direction in a image and then by deviation from horizon…
View deskew.java
public double doIt(BufferedImage image) {
final double skewRadians;
BufferedImage black = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_BYTE_BINARY);
final Graphics2D g = black.createGraphics();
g.drawImage(image, 0, 0, null);
g.dispose();
skewRadians = findSkew(black);
System.out.println(-57.295779513082320876798154814105 * skewRadians);
return skewRadians;
View svg.vba
' svg.vba released 11.08.2002
Private Function get_export_scaling_factor() As Single
'' point to pixel conversion factor
get_export_scaling_factor = (4 / 3)
End Function
View hosts
#UPDATE:2013-07-07 21:01
127.0.0.1 localhost
#SmartHosts START
#Google Services START
203.208.46.200 0.docs.google.com
203.208.46.200 0.drive.google.com
203.208.46.200 1.docs.google.com
View monitrc
###############################################################################
## Monit control file
###############################################################################
##
## Comments begin with a '#' and extend through the end of the line. Keywords
## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
##
## Below you will find examples of some frequently used statements. For
## information about the control file, a complete list of statements and
## options please have a look in the monit manual.
@witwall
witwall / pdf2bmp.cc
Last active Aug 29, 2015
Converting PDF to Bitmap with the help of PDFium and EasyBMP
View pdf2bmp.cc
//for detail, please visit
//http://blog.rubypdf.com/2014/07/08/convert-pdf-to-bitmap-with-pdfium
//do not forget #include "EasyBMP.h" first
static void WriteBmp(const char* pdf_name, int num,
const char* buffer, int stride
, int width, int height) {
BMP bmp;
bmp.SetSize(width,height);
// Set its color depth to 32-bits
bmp.SetBitDepth(32);
@witwall
witwall / pdfdecrypt.cpp
Created Jul 10, 2014
Decrypt PDF(remove pdf password and limitations) with pdfium
View pdfdecrypt.cpp
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../fpdfsdk/include/fpdfview.h"
#include "../fpdfsdk/include/fpdfsave.h"
/*
author:Steven Lee
You can’t perform that action at this time.