Skip to content

Instantly share code, notes, and snippets.

View yurydelendik's full-sized avatar

Yury Delendik yurydelendik

View GitHub Profile
@yurydelendik
yurydelendik / fakelocale.html
Created April 30, 2012 17:56
Fake locale translator
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script>
var table = "ãь¢Ðε£ģНiʃқḻмпOÞȡг§ţȗṿẂӾӳƩ";
@yurydelendik
yurydelendik / gist:2579279
Created May 2, 2012 19:02 — forked from brendandahl/gist:2579276
Change Channel Owner
// Keep the URL the same so the browser sees it as the same.
channel.originalURI = aRequest.URI;
channel.asyncOpen(proxy, aContext);
var securityManager = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
log('got secruity manager!');
var uri = ioService.newURI('resource://pdf.js/web/viewer.html', null, null);
var principal = securityManager.getCodebasePrincipal(uri);
log('created principal!');
channel.owner = principal;
log('hey we changed the owner!');
@yurydelendik
yurydelendik / getLineLineIntersection.js
Created May 21, 2012 03:36
getLineLineIntersection
var epsilon = 1e-8;
function getLineLineIntersection(x1, y1, x2, y2, x3, y3, x4, y4, collinearity) {
// creating coefficients for lines in the form: a * x + b + y = c
var a1 = -(y2 - y1), b1 = (x2 - x1), c1 = (x2 - x1) * y1 - (y2 - y1) * x1;
var a2 = -(y4 - y3), b2 = (x4 - x3), c2 = (x4 - x3) * y3 - (y4 - y3) * x3;
// finding the intersection
var d = a1 * b2 - a2 * b1;
if (d == 0) {
// two lines are parallel to each other
<!doctype html>
<canvas id="sample" width="400" height="400"></canvas>
<script>
var sample = document.getElementById("sample");
function createSample() {
var ctx = sample.getContext('2d');
var width = sample.width, height = sample.height;
var pixels = ctx.getImageData(0, 0, width, height);
var data = pixels.data;
var size0 = 5, size1 = 8;
@yurydelendik
yurydelendik / gist:2831211
Created May 29, 2012 22:38
Setting up the shumway gh-pages
Per http://oli.jp/2011/github-pages-workflow/
Do Setting up GitHub Pages:
$ cd /path/to/fancypants
$ git symbolic-ref HEAD refs/heads/gh-pages
$ rm .git/index
$ git clean -fdx
$ echo "Shumway home" > index.html
$ git add .
@yurydelendik
yurydelendik / gist:3219490
Created July 31, 2012 18:57
Processing.js snippets
// ------ simple sketch
line(10, 10, 90, 90);
// ------ eye
void setup()
{
size(200, 200);
smooth();
}
diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h
--- a/content/base/public/nsIDocument.h
+++ b/content/base/public/nsIDocument.h
@@ -1424,17 +1424,17 @@ public:
*/
bool IsStaticDocument() { return mIsStaticDocument; }
/**
* Clones the document and subdocuments and stylesheet etc.
* @param aCloneContainer The container for the clone document.
@yurydelendik
yurydelendik / .htaccess
Last active August 7, 2023 14:01
CORS for pdf.js
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "http://mozilla.github.io"
</IfModule>
@yurydelendik
yurydelendik / gist:3764535
Created September 21, 2012 23:41
alias for .git/config to squash commits
[alias]
squash = !sh -c 'git checkout mozilla/master && git merge --no-commit --squash $0 && git checkout -B $0 && git commit -e'
@yurydelendik
yurydelendik / gist:3934952
Created October 22, 2012 22:14
fix annotations
diff --git a/web/viewer.js b/web/viewer.js
index d1ed8d3..217ff85 100644
--- a/web/viewer.js
+++ b/web/viewer.js
@@ -1801,16 +1801,17 @@ var PageView = function pageView(container, pdfPage, id, scale,
element.style.height = Math.ceil(rect[3] - rect[1]) + 'px';
return element;
}
- function createCommentAnnotation(type, item) {
+ function createTextAnnotation(item) {