Skip to content

Instantly share code, notes, and snippets.

View ariunbat's full-sized avatar

Ariunbat ariunbat

View GitHub Profile
@ariunbat
ariunbat / fetch
Last active December 1, 2015 13:44
Fetch Settings for Sublime Text 2
{
"files":
{
"avgrundjs": "https://raw.github.com/voronianski/jquery.avgrund.js/master/js/jquery.avgrund.js",
"backbone": "http://documentcloud.github.com/backbone/backbone.js",
"backbone.localStorage": "https://raw.github.com/jeromegn/Backbone.localStorage/master/backbone.localStorage.js",
"backbone.min": "http://documentcloud.github.com/backbone/backbone-min.js",
"d3js": "http://d3js.org/d3.v3.min.js",
"raphaeljs": "http://github.com/DmitryBaranovskiy/raphael/raw/master/raphael-min.js",
"history": "https://raw.github.com/balupton/history.js/master/scripts/compressed/history.js",
@ariunbat
ariunbat / gist:2064776
Created March 17, 2012 19:52 — forked from padolsey/gist:527683
JavaScript: Detect IE
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@ariunbat
ariunbat / pls2audio.html
Created April 11, 2012 19:42 — forked from Offbeatmammal/pls2audio.html
HTML5, JavaScript to load a .pls file to <audio> tag. Uses error and ended events to move to the next item
<! DOCTYPE html>
<html>
<head>
<title>PLS Processor</title>
<!-- needed for IE9 to ensure it treats page as HTML5 properly -->
<meta http-equiv="X-UA-Compatible" content="IE=9" >
</head>
<body>
<p>Audio PLS processor<p>
<audio id="audio" controls="controls"></audio >
@ariunbat
ariunbat / assert.sublime-snippet
Created January 19, 2013 17:41
Assert function
<snippet>
<content><![CDATA[
var assert = function(value, msg){
if(!value)
throw(msg|| (value + " does not equal true"));
};
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>assert</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
@ariunbat
ariunbat / assertequal.sublime-snippet
Created January 19, 2013 17:44
AssertEqual function
<snippet>
<content><![CDATA[
var assertEqual = function(val1, val2, msg){
if(val1!=val2)
throw (msg||(val1+" does not equal " + val2));
};
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>assertequal</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
@ariunbat
ariunbat / memoizer.js
Created February 1, 2013 18:07
This function helps you save already calculated function's value to the array and prevents you from loading the function again and again. Credit to Douglas Crockford.
/*
Memoizer function takes an initial memo array and fundamental function.
It returns a shell function that manages the memo store and that calls the functamental function as needed.
We pass the shell function and the function's parameters to the fundamental function.
For example: Fibonacci series creater.
var fibonacci = memoizer([0,1], function(shell, n){
return shell(n-1) + shell(n-2);
});
*/
@ariunbat
ariunbat / selffunction.sublime-snippet
Created February 10, 2013 11:24
Self-invoking function
<snippet>
<content><![CDATA[
(function(){
${1}
})();
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>funs</tabTrigger>
@ariunbat
ariunbat / starr_rose_mesh
Created March 8, 2013 19:09
Starr Rose Mesh
// set some global vars
var _c;
// params for making rose flower play with these settings to make all kinds of different shapes
var a = 8;
var b = 16;
var c = 16;
// number of flowers to draw. each one progressively smaller
var shades = 10;
@ariunbat
ariunbat / encodeValue.js
Created April 7, 2013 18:52
Escape function for AJAX
function encodeValue(val){
var encodedVal;
if(!encodeURIComponent){
encodedVal = escape(val);
//Fix the omissions
encodedVal = encodedVal.replace(/@/g, '%40');
encodedVal = encodedVal.replace(/\//g, '%2F');
encodedVal = encodedVal.replace(/\+/g, '%2B');
}
else{
@ariunbat
ariunbat / xhr.js
Created April 11, 2013 15:24
XHR wrapper
function createXHR(){
try {return new XMLHttpRequest();} catch(e){}
try {return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch(e){}
try {return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch(e){}
try {return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e){}
try {return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){}
return null;
}