Skip to content

Instantly share code, notes, and snippets.

@TechNinjaWeb
TechNinjaWeb / event-handling.vb
Last active January 22, 2017 05:30
Handling event detection and intent
Private LastActiveControl As Control = Me ' initialize on form creation
Protected Overrides Sub UpdateDefaultButton()
' Just added a IsNot condition to clarity
If (LastActiveControl Is txtNumberOfDrinks) AndAlso
((ActiveControl Is btnClear) OrElse (ActiveControl Is btnExit)) Then
' Only problem is that it tries to validate twice upon tabbing away (only once on click)
ElseIf (LastActiveControl Is txtNumberOfDrinks) AndAlso
((ActiveControl IsNot btnClear) OrElse (ActiveControl IsNot btnExit)) Then
validateForm()
@TechNinjaWeb
TechNinjaWeb / HTMLElements
Created May 12, 2016 00:08
Useful Prototypes
/////////////////////////////////////////////////////////////////////////////
// Is Element In View?
// If object's position cannot be determined, no event will fire.
// Define callback argument as a function or object with in and out params
// as listeners for each event.
/////////////////////////////////////////////////////////////////////////////
HTMLElement.prototype.inView = function(cb){
var err;
// Get Window Atribs
var getViewFrame = function(){ return {w: window.innerWidth, h: window.innerHeight, y: window.scrollY }; };
@TechNinjaWeb
TechNinjaWeb / index.tpl.html
Created April 26, 2016 07:00
ES5 Promises & Error Handling
<div id="output">
</div>
@TechNinjaWeb
TechNinjaWeb / app.js
Created April 26, 2016 06:56
Backand Connection Test
var app = angular.module('app', ['backand'])
.controller('appCtrl', function($scope, $http, Backand) {
$scope.message = "Loaded";
$scope.appCtrl = $scope;
var self = this;
self.getUsers = function() {
$http({
method: 'GET',
@TechNinjaWeb
TechNinjaWeb / jquery.rotate.prototype.js
Created April 26, 2016 06:50
jQuery Rotate Selector Prototype
(function($){
$.fn.animateRotate = function(angle, duration, easing, complete) {
return this.each(function() {
var $elem = $(this);
$({
deg: 0
}).animate({
deg: angle
}, {
@TechNinjaWeb
TechNinjaWeb / Angular $AuthService Factory - Mockup
Created April 16, 2016 23:00 — forked from AlphaNerd/Angular $AuthService Factory - Mockup
Simple mockup of Angularjs user authentication service/factory
.factory('$authservice', ['$window', '$localstorage', '$state', function($window, $localstorage, $state) {
// Access local storage for existing user info
var SHIFT = $localstorage.getObject("Shift")
// Does session exist?
if (SHIFT && SHIFT.session.token) {
console.log("$authservice: Existing Session found: ", [SHIFT])
} else {
console.log("$authservice: No session found.")
SHIFT = {
session: {
@TechNinjaWeb
TechNinjaWeb / app.js
Created April 16, 2016 22:58 — forked from AlphaNerd/app.js
Solid framework for secure content, network connection status, and general route setup
// Ionic Starter App
// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
// 'starter.controllers' is found in controllers.js
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'ngCordova'])
.run(function($ionicPlatform, $rootScope, $cordovaNetwork, $state, $authservice) {
$ionicPlatform.ready(function() {
@TechNinjaWeb
TechNinjaWeb / browserify.shim.js
Last active May 14, 2016 18:08 — forked from jshbrntt/gulpfile.js
Gulp + Watchify + Debowerify + Uglify
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Browserify Shims
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// var paths = require('./paths'); // Require Your Paths.JS file
module.exports = {
angular: {
@TechNinjaWeb
TechNinjaWeb / alerts-module.js
Created December 26, 2015 00:58
Custom App - Module Installer - Test Using Require
define(function (require) {
// Function Executes with window[your-module.namespace]
// && selector of div to hold alerts eg: <div id='alert'></div>
// || <div class="alert"></div>
return (function(m, selector) {
// Define The Module To Be Instantiated
var that;
var AlertSystem = that = new m.constructor({
name: 'AlertSystem',
state: {
@TechNinjaWeb
TechNinjaWeb / alerts-module.js
Last active December 21, 2015 12:48
Custom App - Module Installer & Configuration
(function(m, eId) {
// Define The Module To Be Instantiated
var AlertSystem = new m.constructor({
name: 'AlertSystem',
state: {
current: "Dom Module Initialized",
last: m.getModuleProperty('state').prototype.memory
},
init: this.init
});