Skip to content

Instantly share code, notes, and snippets.

@kavun
kavun / $.debounce(d) window.resize events
Last active December 15, 2015 19:38
testing window.resize event with $.debounce
<!doctype html>
<html>
<head>
</head>
<body>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="https://raw.github.com/cowboy/jquery-throttle-debounce/master/jquery.ba-throttle-debounce.min.js"></script>
<script>
function log(s) {
s = s || 'logged something';
@kavun
kavun / WSHRepl.js
Last active April 1, 2021 04:45
JScript in/out console for Windows Script Host
function print(text) {
WScript.Echo('> ' + text);
}
var stdin = WScript.StdIn;
var stdout = WScript.StdOut;
var input;
do {
var input = stdin.ReadLine();
@kavun
kavun / gist:6390166
Created August 30, 2013 14:01
VS2010 search filter
*.vb;*.resx;*.xsd;*.wsdl;*.xaml;*.xml;*.htm;*.html;*.css;*.aspx;*.asmx;*.js;*.ascx;*.cs;*.asa;*.asp;*.txt; *.master
@kavun
kavun / Preferences.sublime-settings
Last active December 22, 2015 00:49
Sublime Text 2 prefs
{
"bold_folder_labels": true,
"caret_style": "phase",
"detect_slow_plugins": false,
"drag_text": false,
"draw_minimap_border": false,
"font_face": "Source Code Pro Medium",
"font_size": 9,
"highlight_line": true,
"highlight_modified_tabs": true,
@kavun
kavun / ns.js
Created September 8, 2013 21:23
namespacer
ns: function (ns) {
var obj = this;
var parts = ns.split('.');
for (var i = 0, l = parts.length; i < l; i++) {
var part = parts[i];
if (typeof obj[part] === 'undefined') {
obj[part] = {};
}
obj = obj[part];
}

Install and Build Raphael

Make sure you have both node and git installed

  • open git bash in the folder where you want the raphael folder created
  • npm install -g grunt-cli install grunt-cli globally so you can access it later to do the grunt build step
  • git clone https://github.com/DmitryBaranovskiy/raphael.git or the url to your repo if you have forked it already
  • cd raphael go to the new folder that git clone created
  • git submodule init initialize the eve submodule (dependency), you can see this defined in the .gitmodules file
  • git submodule update update eve
  • cd dev go to the dev folder (thats where the main package.json file for npm lives)
  • npm install install dependencies from package.json file
// adapted from http://davidwalsh.name/detect-scrollbar-width
function getScrollBarWidth() {
var container = document.createElement('div');
container.style.width = '100px';
container.style.height = '100px';
container.style.overflow = 'scroll';
container.style.position = 'absolute';
container.style.top = '-9999px';
document.body.appendChild(container);
var width = container.offsetWidth - container.clientWidth;
@kavun
kavun / textWidth.js
Last active December 28, 2015 09:29
var textWidth = (function (el) {
document.body.appendChild(el);
el.style.position = 'absolute';
el.style.top = '-1000px';
return function (text) {
el.innerHTML = text;
return el.clientWidth;
};
})(document.createElement('div'));
function t(s, d) {
for(var p in d) {
s = s.replace(new RegExp('{'+ p +'}','g'), d[p]);
}
return s.replace(/{[^}]*}/g, '');
}