Skip to content

Instantly share code, notes, and snippets.

@imaya
imaya / gist:2387655
Created April 14, 2012 20:02
tmp inflate
/**
* JavaScript Inflate Library
*
* The MIT License
*
* Copyright (c) 2012 imaya
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
@imaya
imaya / psd_demo.js
Created September 22, 2012 09:24
psd.js demo script
NodeList.prototype.forEach = Array.prototype.forEach;
window.addEventListener('DOMContentLoaded', function() {
document.getElementById('file').addEventListener('change', onFileSelected, false);
function onFileSelected(e) {
var file = document.getElementById("file").files[0];
var reader = new FileReader();
// remove all canvas
document.querySelectorAll('canvas').forEach(function(element) {
@imaya
imaya / lossless2-data.js
Created September 22, 2012 12:36
lossless2(html5-logo)
var Lossless2DataDirect =
"AQAFwADMAHja7d1PaFxVFMfxoYRAKAkdlZbiFJyCScimDEXQRYUotBCkNtK0olgyxFUEISJYEJHZiCCFiN0FJBsRpGjcNWQT8M9CEEMpBFdqadr8qWasjVr/dOyJWsqQdN6bd++7f873B2fV5iWT+eTN3HvP3Fso+J3529VoUa3SSHmNWsKvabdqbfx8Myl+Z0muN9jGYyb4d+VfqpjgsVbwj/9I/bd6rMUU18E//kP0X8z4OPGP/5D9Nwzc+/GP/5D9FzPe+/GP/5D9N/+8ZfzjX5n/esavxz/+Q/bfyPi1+I/Hv4lKExfXM134xz/+8Y9//OMf//jHP/7xj3/8h+6/in/8R+Z/vmB2XhT/+A/Jf9LfRQX/+I/Uf6v/u5DimviPx7/PXk1fbzLh97ThP+s6N8G/iett9e+T+Me/Ev/DCb4f/vEfq39JvWm+E//41+T//6+baPOa+Md/6P7nM1wT//gP3X8B//jHP/7xj3/8R5nKf8/VvapVBg1cI6TrJblm8x4S5YQ/R5oqw5cQQgghhBBCCCGEEEIIIYQQQgghhBASURqXn3qYorYr/FP4xz+Ff/xTmmr+o0cfxD+ltWqv9N6Hf0prDT52fxf+Kd77xxt5j8dzTWn1PzN1cC/PNaXVf3Wk1M1zTWn1L2McnmtKq3/GwBT+ea7v1M8v9kdby8d78Y9/tf65/+Mf//jHP/7xfycL5w/twz7+7y4xocW/9DlhH//aet/wj//tamKsvEuL/8pATyf28X93iYmComAf/xrHvvjHP/7xj3/8UxH7Xx/twz/+1fr/6RT+8a/X/+pJet/wr9f/1Wfwj3+9/un9wT/+8Y9//Leo+sXD+7X5t7oPyspns8HUX99+FUTdnJu25V/Dvoe59sCJq7W1tSAqlPz+6Xv0fpqL1X0glqfexr/hbLxzypZ/Dfse5joGuPLqCfwbDr0PAY2BT1Twj3/Vc0D4xz/+8e/Cf30M//jX65/eN/xr9r/
@imaya
imaya / lossless2.js
Created September 24, 2012 04:58
decode lossless2 binary
/**
* original source code:
* https://github.com/Moncader/QuickSWF/blob/master/src/tags/lossless.js
* @author Yuta Imaya
* Copyright (C) 2012 Yuta Imaya.
*/
(function(global) {
var USE_TYPEDARRAY = (global.Uint8Array !== void 0);
var USE_BLOBCONSTRUCTOR = false;
try {
@imaya
imaya / androidPutImageDataBug.js
Created September 26, 2012 02:27
detect android default browser putImageData bug
/**
* @return {boolean}
*/
function androidPutImageDataBug() {
/** @type {HTMLCanvasElement} */
var canvas =
/** @type {HTMLCanvasElement} */
document.createElement('canvas');
/** @type {CanvasRenderingContext2D} */
var ctx = canvas.getContext('2d');
@imaya
imaya / arcfour_str.js
Created October 12, 2012 07:19
Arcfour encryption
goog.provide('ArcfourString');
goog.scope(function() {
/**
* Arcfour implementation.
* @param {string} key secret key.
* @param {string} plainString plain text.
* @param {number=} opt_dummyLoop dummy encryption loop count.
* @return {string}
(function(global) {
global.TreeNode = TreeNode;
/**
* @constructor
*/
function TreeNode() {
/** @type {Array.<TreeNode>} */
this.childNodes = [];
@imaya
imaya / rpm.js
Created October 31, 2012 07:16
reverse package merge algorithm
/**
* Reverse Package Merge Algorithm.
* @param {Array.<number>} P sorted probability.
* @param {number} n number of symbols.
* @param {number} L code length limit.
* @return {Array.<number>} code lengths.
*/
function reversePackageMerge(P, n, L) {
/** @type {Array.<number>} */
var l = new Array(L);
@imaya
imaya / gist:4086371
Created November 16, 2012 10:50
zlib.js gunzip demo
<!DOCTYPE html>
<html>
<head>
<script src="gunzip.min.js"></script>
<script>
(function(global) {
var css = './gunzip.demo.css.gz';
var xhr = new XMLHttpRequest();
xhr.open('GET', css, true);
@imaya
imaya / fladdict.js
Created January 15, 2013 08:53
輝度による文字色の除外を追加
function Fladdict(img) {
this.image = img;
this.canvas;
this.context;
this.backgroundColor;
this.textColor = [];
this.edgeColor;
this.colorHistogram;
}