Skip to content

Instantly share code, notes, and snippets.

View wesleytodd's full-sized avatar

Wes Todd wesleytodd

View GitHub Profile
@wesleytodd
wesleytodd / downloading
Created July 17, 2014 02:34
Ways to install node.js in bash
#!/usr/bin/env bash
#
# Inspired by:
# https://github.com/visionmedia/n/blob/master/bin/n
# http://stackoverflow.com/a/8597411
#
# Detect Platform
if [[ "$OSTYPE" == "linux-gnu" ]]; then
@wesleytodd
wesleytodd / angular.js
Last active August 29, 2015 14:05
Example of a very basic module
// Export for Angular
if (angular) {
angular.module('vube.video', [])
.factory([function() {
return VideoSingle;
}]);
}
(function() {
@wesleytodd
wesleytodd / gist:34fd31e9822e6ee567ee
Last active August 29, 2015 14:05
An example of hydrating a media url from an api response
var mockVideo = {
title: 'My Awesome Video',
public_id: 'abc123',
media: {
_links: {
thumbnail: {
template: 'http://frame.thestaticvube.com/snap/{width}x{height}/{public_id}.jpg;t={timestamp}'
},
video: {
template: 'http://video.thestaticvube.com/video/{resolution_id}/{public_id}.mp4'
@wesleytodd
wesleytodd / callbacks.md
Last active August 29, 2015 14:06
Async Control Flow

Callbacks are great

function myDataGetterThingy(done) {
  var xhr = new XMLHttpRequest();
  xhr.onreadystatechange = function() {
    if (xhr.readyStateChange === 4) {
      try {
        var res = JSON.parse(xhr.responseText);
@wesleytodd
wesleytodd / gist:990f0292051c5210abbd
Last active August 29, 2015 14:20
Render example
var pubId = 'the starting value';
var render = function() {
// The right sidebar
var rightSidebar = module.exports = React.render((
<RightSidebar showCloseButton={false}>
<SidebarSection title="Register Complete" ref="register-complete">
<IframeComponent src={"/embed/" + pubId }/>
</SidebarSection>
</RightSidebar>
@wesleytodd
wesleytodd / template.js
Created September 12, 2012 06:47
Simple Templates
var Template = (function(){
return function(t){
if(!(this instanceof Template)){
return new Template(t);
}else{
var me = this;
me.template = t;
return function(data, container){
var out = me.template;
for(var key in data){
@wesleytodd
wesleytodd / backbone_gallery.js
Created October 24, 2012 19:05
Backbone Gallery Notes
@wesleytodd
wesleytodd / wljs.md
Created November 7, 2012 16:31
The White Lion Javascript Library

The White Lion Javascript Library

Important Architecture Choices

  • Modularity: All portions should be stand alone, utilizing the module pattern and dependency injection.
  • Separation Of Concerns(SOC): Using templates and configuration options we need to keep DOM manipulation, HTML, and CSS to a minimum inside the hard-coded JS.
  • Configurability: Nothing can be mandatory, no more "hi-jacking" events or forcing features. All modules and plugins need to be configurable on a site by site basis with logical defaults.
  • Asset Lazy-Loading: Minimize the up-front footprint on page load, relying on loading assets and modules in a way that increases responsiveness.
  • Easy Interface: The interface needs to be easy to use and well documented so that new hires can quickly come up to speed with the available features and best practices.
@wesleytodd
wesleytodd / home.js
Created December 3, 2012 22:39
Example ready method
WL.ready(['plugin1.js','plugin2.js'], function(plugin1, plugin2){
plugin1();
});
WL.ready(function(){
// just maps to jQuery.ready()
});