Skip to content

Instantly share code, notes, and snippets.

@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 / ImportSVGToSymbol.html
Created January 8, 2013 05:06
In Paper.js, use importSVG to import an svg node to a useable symbol and remove it from the DOM.
<!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/paper.js"></script>
<script type="text/paperscript" canvas="canvas">
function SVGSymbol(elem){
var a = new Symbol(paper.project.importSvg(elem));
elem.parentNode.removeChild(elem);
@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 / 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:
@netpoetica
netpoetica / Property.js
Created August 31, 2012 19:00
Properties (Getter and Setter accessible attributes) in JavaScript. An attempt to make variables with getters and settes in JavaScript easily. Basically, make them an object instead. Maybe useful to someone!
​var Property = function(vari){
console.log("Creating a public accessor...");
this.vari = vari;
return function(){
if(arguments.length > 0){
console.log("Setting the variable to " + arguments[0] + "...");
vari = arguments[0];
return;
}
console.log("Getting the variable...");
@netpoetica
netpoetica / Singleton.js
Created August 20, 2012 01:36
A Singleton in JavaScript that truly ensures one instance, can be lazy-loaded (you can instantiate it whenever you need it), and has private and public scope.
/* **
*
* Singleton.js - a true Singleton in JavaScript
*
* A Singleton in JavaScript that truly ensures one instance, can be lazy loaded / you
* can instantiate it whenever you need it and has private and public scope.
*
* @author Keith Rosenberg, netPoetica
*
* */