Skip to content

Instantly share code, notes, and snippets.

@TerryMooreII
TerryMooreII / angular-wysiwyg.js
Created March 25, 2014 16:14
This is commit id 68a580c3d6cb804911d518098b023b35052edc8d for https://github.com/TerryMooreII/angular-wysiwyg/blob/68a580c3d6cb804911d518098b023b35052edc8d/angular-wysiwyg.js repository. This is pasted here so we can embed in Cardinal Solutions blog post.
'use strict';
/*
Usage: <wysiwyg textarea-id="question" textarea-class="form-control" textarea-height="80px" textarea-name="textareaQuestion" textarea-required ng-model="question.question" enable-bootstrap-title="true"></wysiwyg>
options
textarea-id The id to assign to the editable div
textarea-class The class(es) to assign to the the editable div
textarea-height If not specified in a text-area class then the hight of the editable div (default: 80px)
textarea-name The name attribute of the editable div
textarea-required HTML/AngularJS required validation
@TerryMooreII
TerryMooreII / smile-spinner.html
Created April 23, 2014 17:21
Smile bored spinner
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
</head>
<body>
<div>
<i id="spinner" class="fa fa-2x fa-spin fa-smile-o"></i>
@TerryMooreII
TerryMooreII / heartbeat.js
Created May 2, 2014 11:58
Sending the initial heartbeat. - Cardinal Solutions ALF blog post
function heartbeatInit(properties) {
console.log('HeartbeatService.init.heartbeatInit: Sending initial heartbeat to ALF server @ ' + properties.alfServer + ':' + properties.alfServerPort + properties.PATH_TO_ALF_HEARTBEAT_SERVICE + ' for host "' + hostName + '"...');
// Setup the data that's going to be sent to the ALF server on agent init
var initData = {
agentName: properties.agentName,
hostName: hostName,
port: properties.port,
services: properties.services
@TerryMooreII
TerryMooreII / server.js
Created May 2, 2014 12:07
Fully functional web server in 30 lines of code - Cardinal Solutions ALF blog post
var http = require('http');
var path = require('path');
var fs = require('fs');
var base = __dirname;
http.createServer (function(req, res){
pathname = base + req.url;
console.log(pathname);
path.exists(pathname, function(exists){
@TerryMooreII
TerryMooreII / post-route.js
Created May 2, 2014 12:08
Code for creating the POST route - Cardinal Solutions ALF blog post
app.post(new RegExp(routePatterns.post), function(request, response) {
var service = request.params[0];
console.log('ServicesController: Received request to create new ' + service + ' instance /w request=' + request + '...');
// Validate the request
if (!validate(request)){
return errorResponse(response, 'Missing or invalid query parameters');
}
@TerryMooreII
TerryMooreII / route-regex.js
Created May 2, 2014 12:09
Code to generate the Regular Expression - Cardinal Solutions ALF blog post
routePatterns: function(){
var services = alfAgent.properties.services;
var s = [];
for(var i=0; i < services.length; i++){
s.push(services[i].name.toLowerCase());
}
return routePatterns = {
post: "^\/(" + s.join("|") + ")$",
delete: "^\/(" + s.join("|") + ")\/(.+)$"
@TerryMooreII
TerryMooreII / exec-bash-script.js
Created May 2, 2014 12:11
Code to execute the bash script and send the response message - Cardinal Solutions ALF blog post
var executeCommand = function(obj){
exec(obj.cmd, function(err, stdout, stderr){
var data = {
error: err,
stdout:stdout,
stderr: stderr
}
if (!writeToLog(obj.projectName, obj.service, data)){
errorResponse(response, 'Unable to write to log directory, check permissions')
@TerryMooreII
TerryMooreII / write-to-log.js
Created May 2, 2014 12:12
Code to write the log files - Cardinal Solutions ALF blog post
var writeToLog = function(project, service, data){
var date = new Date();
var directory = properties.baseDir + '/logs';
fs.exists(directory, function (exists) {
if (!exists){
fs.mkdirSync(directory);
}
for (var key in data) {
@TerryMooreII
TerryMooreII / azure-angular-service-1.js
Last active August 29, 2015 14:00
azure-angular-service-1.js - Cardinal Solutions blog post: Azure Angular Service
angular.module('azure-mobile-service.module', [])
.service('Azureservice', function Azureservice() {
return {
};
})
@TerryMooreII
TerryMooreII / azure-angular-service-2.html
Created May 2, 2014 12:44
azure-angular-service-2.js - Cardinal Solutions blog post: Azure Angular Service
<script src="http://ajax.aspnetcdn.com/ajax/mobileservices/MobileServices.Web-1.1.3.min.js"></script>