Skip to content

Instantly share code, notes, and snippets.

View ry8806's full-sized avatar

Ryan Southgate ry8806

View GitHub Profile
@ry8806
ry8806 / promise_before.js
Last active April 15, 2016 21:45
AngularJS combining promises
var theResults = [];
someAsyncWork().then(function(result){
return getFirstValue().then(function (value) {
theResults.push(value);
});
}).then(function (result) {
return getSecondValue().then(function (value) {
theResults.push(value);
});
@ry8806
ry8806 / index.html
Last active March 15, 2016 21:50
Multiline Text in Highcharts (SVG)
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/solid-gauge.js"></script>
<script src="script.js"></script>
@ry8806
ry8806 / rendersvg.cs
Created February 11, 2016 19:14
C# server-side rendering with Highcharts
using Svg;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
namespace SvgRenderer
{
public class Renderer
{
public void Render(string svg)
@ry8806
ry8806 / upload.js
Last active February 11, 2016 17:59
C# server-side rendering with Highcharts
// Build the chart with our options
var chart = Highcharts.Chart(options);
var svg = chart.getSVGForExport();
// Post the svg to our server (using jQuery)
$.post("http://myserver.com/api/savesvg", svg, function(result){
});
<div ng-controller="ErrorController">
<div>
<span>{{::model.Message}}</span>
</div>
<div>
<div>
<input ng-click="Ok()" value="OK" type="button" ok />
</div>
</div>
</div>
@ry8806
ry8806 / error-module.js
Last active January 20, 2016 13:13
An Angular Module for handling errors
angular.module('Errors', ['jqueryDialog'])
.service('ErrorService', ['$templateRequest', 'dialogService', function ($templateRequest, dialogService) {
// The template (which references the controller)
var templateUrl = "../error-template.html";
// Request the template and do nothing - so it's in the cache in case we lose internet connection later
$templateRequest(templateUrl);
// Now show the template in a dialog box
this.ShowError = function (info) {
uploaderApp.service('S3UploadService', ['$q', function ($q) {
// Us standard region
AWS.config.region = 'us-east-1';
AWS.config.update({ accessKeyId: '**myAccessKeyId**', secretAccessKey: '**mySecretAccessKey**' });
var bucket = new AWS.S3({ params: { Bucket: 'myTempBucket', maxRetries: 10 }, httpOptions: { timeout: 360000 } });
this.Progress = 0;
this.Upload = function (file) {
var deferred = $q.defer();
@ry8806
ry8806 / uploader-controller.js
Last active November 13, 2019 04:37
Amazon S3 Upload to Bucket angularJS app and controller
// JavaScript source code
var uploaderApp = angular.module('uploaderApp', ['ngFileUpload']);
uploaderApp.run();
uploaderApp.controller('UploadController', ['$scope', 'Upload', 'S3UploadService', function ($scope, Upload, S3UploadService) {
$scope.uploadFiles = function (files) {
$scope.Files = files;
if (files && files.length > 0) {
@ry8806
ry8806 / uploader-index.html
Created December 24, 2015 21:44
Amazon S3 Upload to Bucket html page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<!--<link rel="icon" href="../../favicon.ico">-->
myApp.service("PlayerService", [function () {
this.IsPaused = false;
this.CurrentTrack = null;
this.Play = function (track) {
this.CurrentTrack = track;
this.IsPaused = false;
};
this.Pause = function () {
this.IsPaused = !this.IsPaused;