Skip to content

Instantly share code, notes, and snippets.

@wizard04wsu
wizard04wsu / javascript_resources.md
Created February 4, 2014 21:20 — forked from jookyboi/javascript_resources.md
Here is a set of libraries, plugins and guides which may be useful to your JavaScript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@wizard04wsu
wizard04wsu / css_resources.md
Created February 4, 2014 21:20 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@wizard04wsu
wizard04wsu / getPrototypeOf.js
Last active August 29, 2015 13:56
Cross-browser Object.getPrototypeOf()
//add Object.getPrototypeOf() if it's not supported
// - if the __proto__ property is not supported either, this may break if anything in the object's prototype chain has been tampered with
// - see http://ejohn.org/blog/objectgetprototypeof/
(function (){
"use strict";
function isPrimitive(o){ var t; return o===t || o===null || (t = typeof o)==="number" || t==="string" || t==="boolean"; }
if(!Object.getPrototypeOf){
if(typeof("".__proto__) === "object"){
Object.getPrototypeOf = function getPrototypeOf(object){
@wizard04wsu
wizard04wsu / arrayMaxMin.js
Created February 5, 2014 15:56
Get the maximum and minimum values in an array.
//get max value in an array
//got this from http://addictedtonew.com/archives/482/javascript-array-max-and-equal-height-columns/
if(!Array.prototype.max) Array.prototype.max = function max(){ return Math.max.apply({}, this); };
//get minimum value in an array
if(!Array.prototype.min) Array.prototype.min = function min(){ return Math.min.apply({}, this); };
@wizard04wsu
wizard04wsu / logToBase.js
Last active August 29, 2015 13:56
Get the logarithm of a number to a specified base.
//returns the logarithm of `num` to base `base`
if(!Math.logB){
Math.logB = function logB(num, base){
return Math.log(num)/Math.log(base);
};
}
@wizard04wsu
wizard04wsu / stringPrune.js
Last active August 29, 2015 13:56
String.prototype.prune() is the opposite of String.prototype.slice(). It removes the specified portion of the string and returns what's left, without modifying the original string.
//returns a copy of a string with a portion removed
//(essentially the opposite of `slice`)
//the `end` argument is optional
//str.prune(begin[, end])
if(!String.prototype.prune){
String.prototype.prune = function prune(begin, end){
"use strict";
var newStr = this.slice(0); //make a copy of the string
@wizard04wsu
wizard04wsu / encodeURI.js
Last active August 29, 2015 13:56
Fixes encodeURI() to comply with RFC 3986 where "[" and "]" are reserved characters.
(function (){
"use strict";
var oldEncodeURI = encodeURI;
encodeURI = function encodeURI(str){ return oldEncodeURI(str).replace(/%5B/ig, "[").replace(/%5D/ig, "]"); };
})();
@wizard04wsu
wizard04wsu / encodeStrings.js
Last active August 29, 2015 13:56
Functions to encode/decode text for use in HTML 4.01.
//encode reserved characters in a string for use in HTML
//if `keepValidEntities` is true, the amphersands for valid character entity references will not be encoded
function textToHTML(str, keepValidEntities){
"use strict";
var validEntityNames, rxp;
if(keepValidEntities){
//see http://www.w3.org/TR/html401/sgml/entities.html
validEntityNames = ""+
//markup-significant and internationalization characters
@wizard04wsu
wizard04wsu / bind.js
Last active August 29, 2015 13:56
Cross-browser workaround for function binding
//creates a new function that, when called, has its `this` keyword set to the provided object, with a given sequence of arguments
// preceding any provided when the new function is called
//note: this is only a partial implementation; it may not work as expected in some scenarios.
// For instance, the resulting function cannot be used as a contructor.
if(!Function.prototype.bind){
Function.prototype.bind = function bind(toObject){
"use strict";
var originalFn, boundArgs;
@wizard04wsu
wizard04wsu / objectKeys.js
Created February 5, 2014 21:13
Cross-browser Object.keys()
//returns an array of the properties & methods that are direct properties of an object (i.e., those that have not been inherited)
//see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
if(!Object.keys){
Object.keys = (function (){
"use strict";
var hasOwnProperty = Object.prototype.hasOwnProperty,
hasDontEnumBug = !({toString: null}).propertyIsEnumerable("toString"),
dontEnums = ["toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "constructor"];