Skip to content

Instantly share code, notes, and snippets.

@TechNinjaWeb
TechNinjaWeb / Angular Controller
Created March 30, 2015 01:52
Angular Update Problem
app.controllers
.controller('SupportTicketDetailsCtrl', ['TicketService', '$scope', '$stateParams', '$timeout', '$rootScope', function(Tickets, $scope, $stateParams, $timeout, $rootScope) {
$scope.stateParamsObjectId = $stateParams.objectId;
$scope.message = "Product Detail Controller";
$scope.deleteReply = function(index) {
console.log("Current Ticket", index);
var innerQuery = Tickets;
innerQuery.get({objectId: $(objectId).text()}, function(res) {
$(‘[id=*”abc-“]).each(function(e){
if (e.css(display: none) {
// write function here
}
})
function reduce(arr, fn, initial) {
return (function reduceOne(index, value) {
if (index > arr.length - 1) return value // end condition
return reduceOne(index + 1, fn(value, arr[index], index, arr)) // calculate & pass values to next step
})(0, initial) // IIFE. kick off recursion with initial values
}
module.exports = reduce
@TechNinjaWeb
TechNinjaWeb / ChessBoard_after
Created April 7, 2015 00:59
Eloquent Javascript Exercises
// SECOND ATTEMPT AFTER CHAPTER 4
(function(gridSize, charset){
var grid = gridSize || 8,
chars = charset || ["X", "Y"],
chessBoard = {};
chessBoard.isEven = function(num) {
return num % 2 == 0;
}
@TechNinjaWeb
TechNinjaWeb / BuildViewFunctionality.js
Created December 19, 2015 07:41
Error Handling Test Modules
m.buildView = function(element, node) {
try {
if (element !== 'string' || element !== 'object') throw new Error("Element needs to be a string or Object");
// Set Element Equal to 1st Query Selector for Element
if (element === 'string') element = Array.prototype.slice.call(document.querySelectorAll(element))[0];
// Set Element Equal to HTML Element
if (element === 'object' && element.constructor.name.search('HTML') >= 0) element = element;
m.alertClient('log', "ELEMENT IS?", element);
} catch (e) {
m.throwError(e.message, {arguments: arguments});
@TechNinjaWeb
TechNinjaWeb / http-request-example.php
Created December 20, 2015 15:56
PHP Curl Request Response
<?php
header('Content-type: text/html');
header('Access-Control-Allow-Origin: *');
$string = parse_str($_SERVER["QUERY_STRING"]);
$curl = curl_init();
$timeout = 30;
$ret = "";
if ($_REQUEST["data"]) {
@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
});
@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 / 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 / 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: {