Skip to content

Instantly share code, notes, and snippets.

View obenjiro's full-sized avatar
🎯
Focusing

Alexey Okhrimenko obenjiro

🎯
Focusing
View GitHub Profile
/* MultiFile - A JavaScript library to load multiple files from
tar archives and json_packed files (see http://gist.github.com/407595)
Example: Loading multiple images from a tarball.
MultiFile.load('images.tar', function(xhr) {
this.files.forEach(function(f) {
var e = document.createElement('div');
document.body.appendChild(e);
var p = document.createElement('p');
@kig
kig / gzip.js
Last active August 1, 2019 08:59
TarGZ = function(){};
// Load and parse archive, calls onload after loading all files.
TarGZ.load = function(url, onload, onstream, onerror) {
var o = new TarGZ();
o.onload = onload;
o.onerror = onerror;
o.onstream = onstream;
o.load(url);
return o;
@jdsharp
jdsharp / DirtyCommas.js
Created March 3, 2011 04:17
Quick and dirty code to insert commas after every 3 digits (also handles decimals correctly)
// via @DmitryBaranovsk
function dirtyCommas(num) {
return String(num).replace(/^\d+(?=\.|$)/, function (int) { return int.replace(/(?=(?:\d{3})+$)(?!^)/g, ","); });
}
@fernandezpablo85
fernandezpablo85 / node-curry.js
Created May 4, 2011 15:32
Explanation of the curry function for node.js
function curriedReadFile(path) {
var _done, _error, _result;
var callback = function(error, result) {
_done = true,
_error = error,
_result = result;
};
fs.readFile(path, function(e, r) {
@westonruter
westonruter / set-immediate.user.js
Created July 1, 2011 00:02
User script to add browser support for setImmediate() API. Try on IE10 demo: http://ie.microsoft.com/testdrive/Performance/setImmediateSorting/Default.html
// ==UserScript==
// @name Support for setImmediate() API
// @description Adapted from David Baron's setZeroTimeout() as suggested by Jeff Walden <http://dbaron.org/log/20100309-faster-timeouts>. Try on <http://ie.microsoft.com/testdrive/Performance/setImmediateSorting/Default.html>
// @author Weston Ruter (@westonruter) at X-Team <http://x-team.com/>
// @namespace http://weston.ruter.net/
// @include *
// ==/UserScript==
(function(window){
// Abort if we already have an implementation
@shimondoodkin
shimondoodkin / WebKit contentEditable focus bug workaround.html
Created July 13, 2011 19:28
WebKit contentEditable focus bug workaround
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>WebKit contentEditable focus bug workaround</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.6.2.js'></script>
<script type='text/javascript'>
//<![CDATA[
$(function(){
@tsaniel
tsaniel / LICENSE.txt
Created July 22, 2011 05:58 — forked from 140bytes/LICENSE.txt
isPrimeNumber (using RegExp)
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@lalinsky
lalinsky / fpcmp.py
Created August 8, 2011 16:52
Very simple way to compare Chromaprint fingerprints
import chromaprint
popcnt_table_8bit = [
0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
@sugyan
sugyan / xdr.js
Created September 29, 2011 09:36
XDomainRequest onprogress
var http = require('http');
http.createServer(function (req, res) {
if (req.url === '/stream') {
res.writeHead(200, {
'Access-Control-Allow-Origin': '*'
});
res.write(Array(257).join(' '));
setInterval(function () {
res.write('hoge');
@gre
gre / easing.js
Last active June 27, 2024 15:37
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the COPYING file for more details.
*/
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {