Skip to content

Instantly share code, notes, and snippets.

Yury Delendik yurydelendik

Block or report user

Report or block yurydelendik

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
@yurydelendik
yurydelendik / gist:8787043
Created Feb 3, 2014
Parse network monitor cap file
View gist:8787043
var sourceAddress = [192,168,1,2];
var targetAddress = [192,168,1,1];
function readCapFile() {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'test.cap');
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
var file = new Uint8Array(xhr.response);
if (file[0] !== 0x47 || file[1] !== 0x4D) throw new Error('invalid cap file');
@yurydelendik
yurydelendik / badfillrule.html
Created Feb 18, 2014
Minimal test case to replicate linux firefox 27 bug
View badfillrule.html
<canvas id="c"></canvas>
<script>
var c = document.getElementById('c');
var ctx = c.getContext('2d');
ctx.transform(10, 0, 0, 10, 0, 0);
ctx.rect(10, 5, 1, 1);
ctx.fillStyle = 'red';
// ctx.mozFillRule = 'evenodd'; // also bad
// ctx.fill(); // okay
ctx.fill('evenodd');
View sha1.js
// http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
var W = new Int32Array(80);
function sha1(s) {
// 6.1.1 SHA-1 Preprocessing
var H = new Int32Array([0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0]);
// 5.1 Padding the Message
var sLength = s.length, sLength8 = sLength << 3;
var length = (((sLength8 + 64) | 511) + 1) >> 3;
var m = new Uint8Array(length);
for (var i = 0; i < sLength; i++) {
@yurydelendik
yurydelendik / config
Created Mar 3, 2014
github try branch alias
View config
[alias]
try = !sh -c 'IFS=\":\" read -ra ARGS <<< \"$0\" && git fetch https://github.com/${ARGS[0]}/pdf.js.git ${ARGS[1]} && git checkout FETCH_HEAD'
@yurydelendik
yurydelendik / overview.html
Created May 10, 2014
Renders all pages at once
View overview.html
<!doctype html>
<html>
<head>
<!-- In production, only one script (pdf.js) is necessary -->
<!-- In production, change the content of PDFJS.workerSrc below -->
<script type="text/javascript" src="../../src/shared/util.js"></script>
<script type="text/javascript" src="../../src/shared/colorspace.js"></script>
<script type="text/javascript" src="../../src/shared/function.js"></script>
<script type="text/javascript" src="../../src/shared/annotation.js"></script>
View encodeToPNG.js
var dumpImage = (function() {
var crcTable = [];
for (var i = 0; i < 256; i++) {
var c = i;
for (var h = 0; h < 8; h++) {
if (c & 1)
c = 0xedB88320 ^ ((c >> 1) & 0x7fffffff);
else
c = (c >> 1) & 0x7fffffff;
}
@yurydelendik
yurydelendik / functions4
Created Aug 2, 2014
FunctionType 4 usage
View functions4
<<
/FunctionType 4
/Length 179
/Range [0 1 0 1 0 1 0 1]
/Domain [0 1]
>>
stream
{ 0 0 0 0 5 4 roll 0 index 3 -1 roll add 2 1 roll pop dup 1 gt { pop 1 } if 4 1 roll dup 1 gt { pop 1 } if 4 1 roll dup 1 gt { pop 1 } if 4 1 roll dup 1 gt { pop 1 } if 4 1 roll }
endstream
<<
View ber.js
// http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf
var UNIVERSAL_TAG_CLASS = 0;
var EOC_TAG = 0;
var BOOLEAN_TAG = 1;
var INTEGER_TAG = 2;
var NULL_TAG = 5;
var OBJECT_ID_TAG = 6;
var RELATIVE_OBJECT_ID_TAG = 13;
var PRINTABLE_STRING_TAG = 19;
View test_subpixel.html
<canvas id="c" width="600" height="400" style="width: 600px; height: 400px"></canvas>
<script>
var c = document.getElementById('c');
var devicePixelRatio = window.devicePixelRatio || 1;
var backingStoreRatio = 1;
var ratio = 1;
if (devicePixelRatio !== backingStoreRatio) {
ratio = devicePixelRatio / backingStoreRatio;
c.width *= ratio;
c.height *= ratio;
View viewer1.html
<!DOCTYPE html>
<!--
Copyright 2012 Mozilla Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
You can’t perform that action at this time.