Skip to content

Instantly share code, notes, and snippets.

View yurydelendik's full-sized avatar

Yury Delendik yurydelendik

View GitHub Profile
@yurydelendik
yurydelendik / BUILD
Created April 16, 2013 16:53
Building jp2a
export PATH=/Users/yury/Work/emscripten:$PATH
cd jpeg-9
emconfigure ./configure
emmake make
cd ..
cd jp2a-1.0.6/src
emcc *.c ../../jpeg-9/.libs/libjpeg.a -I ../../jpeg-9/ -I ../include/ -D'PACKAGE_STRING="emscripten"' -D'PACKAGE_BUGREPORT="yury"' -o ../../jp2a.js
cd ../..
@yurydelendik
yurydelendik / vp6f-ff.diff
Created April 29, 2013 12:08
Enable VP6F for Firefox
diff --git a/content/media/gstreamer/GStreamerFormatHelper.cpp b/content/media/gstreamer/GStreamerFormatHelper.cpp
--- a/content/media/gstreamer/GStreamerFormatHelper.cpp
+++ b/content/media/gstreamer/GStreamerFormatHelper.cpp
@@ -33,24 +33,25 @@ char const *const GStreamerFormatHelper:
{"video/mp4", "video/quicktime"},
{"video/quicktime", "video/quicktime"},
{"audio/mp4", "audio/mpeg, mpegversion=(int)4"},
{"audio/x-m4a", "audio/x-m4a"},
{"audio/mpeg", "audio/mpeg, mpegversion=(int)1"},
{"audio/mp3", "audio/mpeg, mpegversion=(int)1"},
@yurydelendik
yurydelendik / promises.js
Last active December 18, 2015 00:59
Promises/A+ implementation
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* 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
*
$ python stats/statcmp.py sp2_orig.stat sp2_ref.stat
-- Grouped By browser, stat --
browser | stat | Baseline(ms) | Current(ms) | +/- | % | Result(P<.05)
---------------------------------------------------------------------------------
firefox | Font Loading | 1 | 1 | -0 | -6.63 | slower
firefox | Overall | 78 | 75 | 3 | 3.37 | faster
firefox | Page Request | 21 | 17 | 4 | 17.59 | faster
firefox | Rendering | 55 | 56 | -1 | -1.66 | slower
-- Grouped By browser, pdf, stat --
@yurydelendik
yurydelendik / gist:5953383
Created July 8, 2013 23:31
Making simple barcode scanner for Firefox OS
@yurydelendik
yurydelendik / droidscreen.html
Created July 17, 2013 18:49
poor man droid screencast
<canvas id="screencap" onclick="turn()"></canvas>
<script>
var angle = 0;
function turn() {
angle = (angle + 90) % 360;
}
function readImage() {
var img = new Image();
img.onload = function () {
@yurydelendik
yurydelendik / pdfinfo.js
Last active December 20, 2015 09:38
Utility to extract PDF info
fs = require('fs');
function fromPdfString(s) {
var t = '';
for (var i = 0; i < s.length; i++) {
if (s[i] != '\\') {
t += s[i];
continue;
}
if (s[i + 1] < "A") {
@yurydelendik
yurydelendik / gist:6195643
Last active December 20, 2015 21:09
Checking if DOM element is in view
function isInView(element) {
// set initial bounds
var bounds = element.getBoundingClientRect();
var left = bounds.left, top = bounds.top;
var right = bounds.right, bottom = bounds.bottom;
var currentElement = element;
while (true) {
if (!currentElement.offsetParent) {
return false; // 'display: none;' not visible
}
@yurydelendik
yurydelendik / gist:8117617
Created December 24, 2013 20:38
Getting the native DPI
function getDPI() {
var native = document.createElement('div');
native.setAttribute('style', 'width:0px; width:100mozmm; position: fixed;');
document.body.appendChild(native);
var standard = document.createElement('div');
standard.setAttribute('style', 'width:100mm; position: fixed;');
document.body.appendChild(standard);
var dpi = Math.round(native.offsetWidth / standard.offsetWidth * 96);
native.remove();
standard.remove();
@yurydelendik
yurydelendik / gist:8787043
Created February 3, 2014 16:24
Parse network monitor cap file
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');