Skip to content

Instantly share code, notes, and snippets.

@cubicleDowns
cubicleDowns / gist:60920fb09f6b8346362abc76b35a0bf9
Created May 15, 2016 07:34
Center everything CSS / HTML.
// http://howtocenterincss.com/#contentType=div&horizontal=center&vertical=middle&browser.IE=11
<div style="display:flex;justify-content:center;align-items:center;">
<div></div>
</div>
@cubicleDowns
cubicleDowns / speedup.js
Created May 3, 2016 22:37
Angular Speedup - Disable Debug Info
.config(function($compileProvider) {
$compileProvider.debugInfoEnabled(false);
})
@cubicleDowns
cubicleDowns / Gource a git video
Created March 17, 2016 08:13
Script to output a source tree video of all commits via gource.
# install brew
#
# download gource
# brew install all pre-reqs for gource.
#
# configure, make, make install
#
# use following script to output a movie.
# -s is seconds per day. In this example, 1 second is 10 days. 1/10 == 0.1 You'll want to tweak this value.
#
/**
* This gulpfile will copy static libraries and a index.html file as well as
* merge, babelify and uglify the rest of the javascript project.
*
* TODO:
* - Separate media, libs and src with different watchers.
* - Media and libs should only be copied to dist if they are different sizes.
*
* The expected project is to be laid out as such:
*
@cubicleDowns
cubicleDowns / getscopes.js
Created November 7, 2014 18:07
Returns list of scopes. Requires underscore. From here: http://larseidnes.com/2014/11/05/angularjs-the-bad-parts/
function getScopes(root) {
var scopes = [];
function traverse(scope) {
scopes.push(scope);
if (scope.$$nextSibling)
traverse(scope.$$nextSibling);
if (scope.$$childHead)
traverse(scope.$$childHead);
}
traverse(root);
@cubicleDowns
cubicleDowns / ngExceptions.js
Created October 13, 2014 16:42
Angular Error Exception Module
//inject the module as such
var myApp = angular.module("myApp", ['ngExceptions'])
// put this in one file.
(function(window, angular) {'use strict';
/**
* @ngdoc module
* @name ngExceptions
* @description
*
@cubicleDowns
cubicleDowns / threefactory.js
Last active April 6, 2022 03:03
Example of a THREEjs factory and an exposed API.
"use strict";
tttApp.factory('ThreeEnv', function ($http, $log, $rootScope ) {
var demo,
rotateCamera = true,
canvas = document.getElementById('ttt-canvas');
/**
* Initialize the 3D scene.
@cubicleDowns
cubicleDowns / controller.js
Created February 9, 2014 21:48
Example of an AngularJS controller accessing a THREEjs factory. In this example, I am simply calling the exposed API to modify the THREEjs scene.
"use strict";
tttApp.controller('TTTController', function ($scope, ThreeEnv) {
$scope.dims = 3;
$scope.usercolor = "#0000FF";
$scope.username = "Player1";
$scope.userfirst = false;
@cubicleDowns
cubicleDowns / clickDirective.js
Created February 9, 2014 21:44
Example of using an AngularJS directive to interact with a THREEjs factory.
"use strict";
tttApp.directive("selectcube", function(ThreeEnv){
return {
restrict: "A",
link: function(scope, element){
var offsetLeft = element[0].offsetLeft,
offsetTop = element[0].offsetTop,
@cubicleDowns
cubicleDowns / object4d-manager.js
Last active December 31, 2015 16:49
Object4D animation and tweening. You can read more on my blog, http://blog.tempt3d.com/
var Demo = Demo || {};
// This object manages all of the 4D objects.
// Between renders, it'll take the difference between the last render and the current time.
// This Time Delta is passed to each Object4D object.
// Each Object4D object will then move a distance based upon their individually set speed,
Demo.Manager = function () {
this.clock = new Demo.Clock();