Skip to content

Instantly share code, notes, and snippets.

Yakov Shafranovich yakovsh

Block or report user

Report or block yakovsh

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
@yakovsh
yakovsh / 2016_01_31-remove_interpolation.java
Created Feb 1, 2016
Remove interpolation flag from images in a pdf file
View 2016_01_31-remove_interpolation.java
import com.itextpdf.text.pdf.*;
import com.itextpdf.text.pdf.parser.PdfImageObject;
import java.io.FileOutputStream;
/**
* This remove the interpolation flag in images in a given PDF file using iText 5.
* Requires: iText 5
*
* For more info, see:
@yakovsh
yakovsh / 2007_07_25-djvu2pdf.sh
Created Jan 24, 2016
Converting from DJVU to PDF
View 2007_07_25-djvu2pdf.sh
#!/bin/sh
#
# Here is the software that is needed for the conversion to take place:
# 1. DjVuLibre .
# 2. LibTiff .
#
# NOTE: The ddjvu utility has an option to convert specific layers. One common mistake is to convert only the mask layer
# or the foreground layer . Technically speaking, the mask layer is the one that should have the actual text but in
# practice I have seen that the the DjVu encoder occasionally puts portions of the text in the background layer. Thus,
# if you only take the foreground or mask layers, you will lose those bits in the background. If your specific files
@yakovsh
yakovsh / 2007_11_09-flatten_pdf.sh
Created Jan 18, 2016
Flattening Transparencies in PDF with Free Tools
View 2007_11_09-flatten_pdf.sh
#!/bin/bash
#
# This script flattens transparencies in PDF files. To use, run the following:
# 2007_11_09-flatten_pdf.sh [input.pdf] [output.pdf]
#
# You will need xpdf-tools and ps2pdf to be installed
#
pdftops -origpagesizes -level3 $1 temp.ps
ps2pdf -dPDFX temp.ps $2
@yakovsh
yakovsh / 2005_01_03-ups_tracking.js
Created Jan 18, 2016
Tracking UPS Packages via JavaScript
View 2005_01_03-ups_tracking.js
/**
* A post at TechDigits [https://web.archive.org/web/20050311025802/http://techdigits.blogspot.com/2004/12/ups-package-tracking-with-rss.html]
* about tracking UPS packages via RSS and web services got me thinking if the same is possible via Javascript and
* the XmlHttpRequest object (in IE and Mozilla). Since Google's Gmail and Google Suggest started using that object,
* it has become more popular. So after some thinking, I put together the following quick and dirty code snippet
*
* I don't know how useful this can be since the security information is exposed, but it is a nice hack.
*/
req = new XMLHttpRequest();
var strXML = '<?xml version='1.0'?>' +
@yakovsh
yakovsh / 2008_02_23-pdf_multiplier.java
Created Jan 17, 2016
Multiplies pages inside a PDF file, requires iText 2.0.8
View 2008_02_23-pdf_multiplier.java
/*
* To compile and run:
*
* javac -classpath MultiplyPDF.java
* java -classpath iText-2.0.8.jar MultiplyPDF
*
*/
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.PageSize;
@yakovsh
yakovsh / 2004_09_22-cardexport.sh
Created Jan 17, 2016
This script is used to load and unload external SD cards in Palm Pilot devices that are made available to the OS as a USB drive by CardExport II # program,
View 2004_09_22-cardexport.sh
#!/bin/sh
#
# This script is used to load and unload external SD cards in Palm Pilot
# devices that are made available to the OS as a USB drive by CardExport II
# program, made by www.softick.com.
#
# Please make sure that /mnt/usbdrive directory exists and that you have
# the usb-storage support in your kernel. You must be root to run this.
#
# Usage: cardexport {start|stop}
View 2000_12_14-ie_title_changer.vbs
'
' Based on column by Walter Mossberg <mossberg@wsj.com>. Check out his
' page at http://pctech.wsj.com
'
Dim strName
Dim WshShell
Dim strOldTitle
Dim strNewTitle
Dim intTemp
@yakovsh
yakovsh / 2004_10_12-ie_cookies.html
Created Jan 17, 2016
Making Cookies Work in IE
View 2004_10_12-ie_cookies.html
<!--
Recently I had a weird problem while using Tomcat - sessions would get lost when using Microsoft's Internet Explorer.
Since Tomcat stores the session id as JSESSIONID cookie, the session would get lost when the cookie is not stored.
Same behavior occurs with other web servers including IIS and Resin.
After further research, it seems that IE does not store cookies at default privacy settings unless a P3P policy is
provided for the site. In order to bypass this problem, a basic P3P policy needs to defined and included in the site.
I used IBM's P3P editor to generate a basic P3P XML policy file and the following snippet of HTML code to enable it.
This is still true as of 2011: [http://blog.toppingdesign.com/2011/11/18/ie-iframe-p3p-cookies-oh-my/]
@yakovsh
yakovsh / 2006_01_03-js_highlight.js
Last active Jan 17, 2016
Inobstrusive Form Field Highlighting in JavaScript
View 2006_01_03-js_highlight.js
/*
* One of the recent problem that I ran across at work is an easy way to do highlighting for form fields.
* Of course the best way would be CSS 2
* (as shown here [http://www.cssdrive.com/index.php/examples/exampleitem/focus_pseudo_class/]) but alas,
* IE does not support that.
*
* The alternative is JavaScript onFocus and onBlur method. However, one thing which I also wanted to avoid
* is changing over 200 different pages in our system to add those in. So instead, I wrote a simple piece of
* Javascript which attaches the event handlers on the fly. The best part about this is that the actual form
* does not need to be changed - just include the Javascript on the bottom of your webpage. The code is as follows
@yakovsh
yakovsh / 2005_06_03-remove_vowels_from_hebrew.js
Last active Jun 4, 2019
Removing Vowels from Hebrew Unicode Text
View 2005_06_03-remove_vowels_from_hebrew.js
/*
* One of the questions that recently came up is how to remove vowels from Hebrew characters in Unicode
* (or any other similar language). A quick look at Hebrew Unicode chart shows that the vowels are all
* located between 0x0591 (1425) and 0x05C7 (1479). With this and Javascript's charCodeAt function, it
* is trivial to strip them out with Javascript as follows
*
* Live demo is available here:
* https://jsfiddle.net/js0ge7gn/
*/
You can’t perform that action at this time.