Skip to content

Instantly share code, notes, and snippets.

@netpoetica
netpoetica / .eslintrc.js
Last active February 22, 2017 00:52 — forked from dmnsgn/.eslintrc.js
.eslintrc Google JavaScript Style Guide (eslint v0.24.1)
{
// http://eslint.org/docs/rules/
"env": {
"browser": true, // browser global variables.
"node": false, // Node.js global variables and Node.js-specific rules.
"worker": false, // web workers global variables.
"amd": false, // defines require() and define() as global variables as per the amd spec.
"mocha": false, // adds all of the Mocha testing global variables.
"jasmine": false, // adds all of the Jasmine testing global variables for version 1.3 and 2.0.
@netpoetica
netpoetica / Clevar.js
Last active December 21, 2015 05:49
Clevar constructs an accessor function that retains its own History Store and keeps the value absolutely private. Neat utility for tracking history of a variable over time.
var Clevar = function(value){
// Constructs an accessor function that retains its own History Store.
var _this = this;
var _history = []; // Indexable history (newest to oldest)
// Define static objects, only the first time Clevar is run.
Clevar.Record = Clevar.Record || function(value){
this.created = new Date();
this.value = value;
};
@netpoetica
netpoetica / .vimrc
Last active December 11, 2015 23:58 — forked from snuggs/.vimrc
" make Vim more useful
set nocompatible
" vundle
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" VUNDLES
@netpoetica
netpoetica / Paperjs-ImportSVGFromFile.html
Created January 8, 2013 05:05
Using Paperjs and jQuery, import a .svg file as a symbol into a Paperjs project. Without having to append it to the DOM first and remove it, without having inline SVG.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Paperjs - ImportSVG to Symbol</title>
<script type="text/javascript" src="js/lib/jquery-1.8.3.js"></script>
<script type="text/javascript" src="js/lib/paper.js"></script>
<script type="text/paperscript" canvas="canvas">
function SVGSymbol(file){
@netpoetica
netpoetica / doif.js
Last active December 9, 2015 19:51
doif (pronounced "doof") JavaScript subset
//
// raw whitepaper for functional interface/subset of JS that eliminates logical operations
// similar to IFTTT. Based off of this image/site: https://ifttt.com/products
//
function doIf(cond, cb){
if(cond instanceof Array){
doIfEach(cond, cb);
} else if(cond === true && typeof cb === 'function'){
cb();
@netpoetica
netpoetica / GrokJSScope.js
Created November 1, 2012 22:06
Some simple examples to help grok scope in JS in terms of object literals, functions, prototypes and inheritance
// Grok JS Scope for Object Literals in Various Uses
var name = 'Keith Window';
var obj = {
name: 'Keith Object',
getObjName: function(){
return this.name;
},
getWindowName: function(){
return name;
@netpoetica
netpoetica / MultipleInheritance.js
Created October 27, 2012 19:03
A useful example of prototypal multiple inheritance and how the Prototype chain works
// Useful example of inheritance. We will demonstrate multiple
// levels of inheritance here - objects inheriting from objects
// inheriting from objects :)
// Based on example I found here: http://atomicrobotdesign.com/blog/javascript/a-bit-more-on-javascript-prototypes/comment-page-1/#comment-83258
function Person(name, city, job) {
this.name = name;
this.city = city;
this.job = job;
}
Person.prototype = {
@netpoetica
netpoetica / assert.js
Created September 24, 2012 02:22
A visual and console implementation of a basic assert in JavaScript - assertions with a assertion panel in your browser window without intruding upon your other content.
/*
assert.js
by keith rosenberg / netpoetica
An assert function that will create a visual pane if browser is present. It will always
output to console as well. The styling is configured to be position-fixed to the top
right corner (hopefully in most situations, out of the way). I created this after viewing
http://net.tutsplus.com/tutorials/javascript-ajax/quick-tip-quick-and-easy-javascript-testing-with-assert/
@netpoetica
netpoetica / UnitTest.js
Created September 20, 2012 00:52
Unit Test functions for basic client-side unit testing (will add more as I use them in my code)
/*
Name: UnitTest.js
Desc: Various unit testing functions. I use these for running quick tests
especially against JavaScript functions and variables, which are loosely type
and typically can behave unexpectedly
Location: https://dl.dropbox.com/u/30820392/JS_Utils/UnitTest.js
JavaScript Style Guide - Readable, Consistent Code
Yahoo, Google, Mozilla, jQuery recommendations
@netpoetica
netpoetica / utils.js
Created September 20, 2012 00:44
custom cross-browser getElementsByClassname and various utility functions
/*
Name: utils.js
Desc: A collection of JS Utility functions, some authored by me (Keith Rosenberg, http://www.keithrosenberg.com)
and some authored by fellow scripters
Location: https://dl.dropbox.com/u/30820392/JS_Utils/utils.js
JavaScript Style Guide - Readable, Consistent Code
Yahoo, Google, Mozilla, jQuery recommendations
Naming: