Skip to content

Instantly share code, notes, and snippets.

View ariunbat's full-sized avatar

Ariunbat ariunbat

View GitHub Profile
@ariunbat
ariunbat / Sublime Text 3 Settings
Created February 3, 2014 03:25
Sublime Text 3 Settings
{
"bold_folder_labels": true,
"color_scheme": "Packages/User/base16-ocean.dark (SL).tmTheme",
"fade_fold_buttons": false,
"font_face": "Source Code Pro",
"font_size": 11,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
[
-- MySQL Administrator dump 1.4
--
-- ------------------------------------------------------
-- Server version 5.5.16
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
@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;
}
@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 / 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 / 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 / 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 / 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 / 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 / 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 >