Skip to content

Instantly share code, notes, and snippets.

View thebigredgeek's full-sized avatar
💭
Considering new contract opportunities at this time

Andrew E. Rhyne thebigredgeek

💭
Considering new contract opportunities at this time
View GitHub Profile
@thebigredgeek
thebigredgeek / QLite.js
Last active December 30, 2015 23:59
Simple Promise API
(function(scope){ //injected scope to bind
scope.QLite = {};
var publicMembers = scope.QLite, //bind publicMembers to the injected scope
privateMembers = {}; //private members hash for internal closure members
privateMembers.promise = function(){ //the promise object
var self = this,
queue = {};
var InheritableCleanObject = function(){
var publicMembers = this,
privateMembers = {};
publicMembers.hello = function(){
return "world";
};
InheritableCleanObject.prototype = publicMembers;
}
@thebigredgeek
thebigredgeek / gist:6946437
Created October 12, 2013 06:19
weird bug
/**
* This controller is used by youtubeItem directives
* @name angulartodo#youtubeItemController
* @param {Object} $scope An instance of $scope
* @param {Object} $attrs An object containing html attributes bound to this directive
*/
angular.module('angulartodo').controller('youtubeItemController',[
'$scope','$attrs',
function($scope, $attrs){
console.log("hello world!");
@thebigredgeek
thebigredgeek / gist:6943195
Last active December 25, 2015 07:59
Facebook passport
var passport = require('passport'),
FacebookStrategy = require('passport-facebook').Strategy;
/**
* This function handles passport verification
* @param {Object} token Token
* @param {Object} tokenSecret Token secret
* @param {Object} profile Information regarding this user
@thebigredgeek
thebigredgeek / gist:6880344
Created October 8, 2013 06:25
Can't deploy
andrew@andrew-desktop:~/WebstormProjects/angular-quiz$ jitsu deploy
info: Welcome to Nodejitsu rhyneandrew
info: jitsu v0.13.2, node v0.10.18
info: It worked if it ends with Nodejitsu ok
info: Executing command deploy
info: Analyzing application dependencies in node index.js
warn: Local package version appears to be old
warn: The package.json version will be incremented automatically
warn: About to write /home/andrew/WebstormProjects/angular-quiz/package.json
data:
var $q = {defer:function(){return {reject:function(){},resolve:function(){},promise:{}}}}
var db = {query:function(x,y,z){z();}};
var $rootScope = {$apply:function(fn){fn();}};
var x = {
getEvents: function() {
var matchCallback = null;
var reduce = null;
var deferred = $q.defer();
FBase.prototype.register = function(email, password) {
var killFailureListener, killSuccessListener, promise, self;
this.regDeferral = _q.defer();
self = this;
promise = this.regDeferral.promise;
killSuccessListener = null;
killFailureListener = null;
killSuccessListener = _rootScope.$once("angularFireAuth:login", function(event, user) {
killFailureListener();
console.log("hello");
$rootScope.$safeApply = function(fn) {
var phase;
phase = this.$root.$$phase;
if (phase === '$apply' || phase === '$digest') {
if (fn) {
fn();
}
} else {
this.$apply(fn);
}
login: () =>
self = this
@$scope.data.toggle = false #toggle the buttons off
@FB.login(@$scope.data.email, @$scope.data.password).then ((data)-> # Try to login
self.$modalInstance.close # If successful, close the modal
email: self.$scope.data.email # and pass the email address
),(reason)-> # If failure
console.log(reason);
@thebigredgeek
thebigredgeek / gist:6859145
Created October 6, 2013 21:09
$rootScope candy
$rootScope.$safeApply = function (fn) { #safe apply can be accessed from any $scope
var phase;
phase = this.$root.$$phase;
if (phase === '$apply' || phase === '$digest') {
if (fn) {
fn();
}
} else {
this.$apply(fn);
}