Skip to content

Instantly share code, notes, and snippets.

View AlphaNerd's full-sized avatar
💭
Nerding as always

J.Coleman AlphaNerd

💭
Nerding as always
View GitHub Profile
@AlphaNerd
AlphaNerd / controller.js
Created April 20, 2016 11:33
Like/Unlike Button - Great for using localStorage data and using a service in backend to update server.
$scope.i = 0;
$scope.likeClick = function(data){
$scope.data[$scope.i].likes.byUser = $dataservice.likeClick(data);
}
@AlphaNerd
AlphaNerd / app.js
Created April 16, 2016 22:57
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() {
@AlphaNerd
AlphaNerd / localstorageService.js
Created April 16, 2016 22:38
Simple $localstorage service
angular.module('starter.services', [])
.factory('$localstorage', ['$window', function($window) {
return {
set: function(key, value) {
$window.localStorage[key] = value;
},
get: function(key, defaultValue) {
return $window.localStorage[key] || defaultValue;
},
setObject: function(key, value) {
@AlphaNerd
AlphaNerd / Angular $AuthService Factory - Mockup
Created April 16, 2016 22:31
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: {
@AlphaNerd
AlphaNerd / fetchData.php
Created January 17, 2016 03:03
Connect to Joomla Database from custom PHP file and respond with JSON data
<?php
define( '_JEXEC', 1 );
define('JPATH_BASE', '../../../');
require_once ( JPATH_BASE .'/includes/defines.php' );
require_once ( JPATH_BASE .'/includes/framework.php' );
$database = &JFactory::getDBO();
$sql = "SELECT * FROM `b7j6z_content` WHERE `state` = '1'"; // Select data from DB
$database->setQuery( $sql );
$result=$database->loadAssocList();
@AlphaNerd
AlphaNerd / HTML
Created November 18, 2015 01:46
Google Sheets JSON pull
<div id="results"></div>
@AlphaNerd
AlphaNerd / Disqus_Multi-language_Threads.js
Created July 28, 2015 13:56
Disqus API Mod: Force Joomla to pull one Disqus thread for both English and French associated content. Swaps DisqusEmnbed.js [src attr] after initial load.
setTimeout(function(){ //// Timeout required to grab iFrame info after Disqus load
var newURL = jQuery(".moduletable-lang a").attr("href");
var curURL = decodeURIComponent(jQuery("iframe").attr("src"));
var newTitle = "1211-new-brunswick-lagging-behind-other-parts-of-canada-on-wilderness-protection-cpaws-report";
if (jQuery("body").hasClass("fr-fr")){
createNewURL(newURL,newTitle,curURL); /// custome function to build new uri
}
},750);
function createNewURL(newURL,newTitle,curURL){
@AlphaNerd
AlphaNerd / CSS
Created June 15, 2015 13:29
Basic JSON data api pull for creating mockup user lists.
.user-box{
margin:5px;
display:inline-block;
}
.user-image{
max-width:100px;
max-height:100px;
border-radius:100px;
overflow:hidden;
margin:5px;
@AlphaNerd
AlphaNerd / CSS
Created June 9, 2015 14:29
Canada OpenGov Dataset Consumption Example - Plot GPS coordinates on Google Maps.
body{
background:#fff;
}
#map{
height: 300px;
}
#legend{
width:100%;
padding:5px;
text-align:left;
@AlphaNerd
AlphaNerd / CSS
Created June 1, 2015 14:51
Basic Google Map API integration into site. Developed to work with FlexiContent location data. Extract coordinates from GoogleMaps image link, extracting Lat and Long into an array, and then init map.
#map_canvas {
width: 400px;
height: 400px;
margin: 0 auto;
}
.info {
display:none;
}