Skip to content

Instantly share code, notes, and snippets.

View richfergus's full-sized avatar
🇺🇸
merica

Rich richfergus

🇺🇸
merica
View GitHub Profile
@mgebundy
mgebundy / example.html
Last active December 9, 2021 03:26
AngularJS Countdown Directive
<time ng-countdown="1411225200" ng-countdown-finished="toggle()">
<ul class="timer_wrap">
<li class="days">
<span class="value" ng-bind="days">-</span>
<span class="label">days</span>
</li>
<li class="hours">
<span class="value" ng-bind="hours">--</span>
<span class="label">hours</span>
</li>
@marchawkins
marchawkins / google-calendar-event-insert-js
Last active December 14, 2024 06:13
How to connect to the Google Calendar API via the Javascript Client Library and insert an event into a (https://www.google.com/calendar/embed?src=gk0pudanag1bhu35vkv5dunja4%40group.calendar.google.com&ctz=America/New_York). The demo also employs Oauth2 authentication, so the script could read and write to a logged in user's calendar.
<div class="row">
<div class="col-md-2 col-sm-2 col-xs-12">
<button id="authorize-button" style="visibility: hidden" class="btn btn-primary">Authorize</button>
</div><!-- .col -->
<div class="col-md-10 col-sm-10 col-xs-12">
<script type="text/javascript">
// date variables
var now = new Date();
today = now.toISOString();
@Guitlle
Guitlle / pieChartFromObject.js
Created April 22, 2014 21:33
Sparkline pie chart from object. the tooltips are the object keys and the values are the object value for each key.
function pieChartFromObject(data, options, className) {
var labels = [], total = 0,
values = $.map(data, function(value, label) { total += value; labels.push(label); return value; });
var chart = $('<span class="'+className+'">&nbsp;</span>');
options.type = 'pie';
options.tooltipFormat = '<span style="color: {{color}}">&#9679;</span> {{offset:labels}} - {{value}} ({{percent.1}}%)';
options.tooltipValueLookups = { labels: labels} ;
if (total == 0) {
@vladikoff
vladikoff / resource.js
Created April 17, 2014 17:52
Angular $resource and transformResponse
angular.module('itemServices', ['ngResource'])
.factory('Item', ['$resource',
function ($resource) {
return $resource('items/:id',
{id: '@id'},
{
query: {
isArray: true,
method: 'GET',
params: {},
@jakemmarsh
jakemmarsh / controllers.js
Last active May 20, 2019 10:15
AngularJS Service with Controller for access to Google API with Javascript Client (and RequireJS)
define(['angular', 'services'], function (angular) {
'use strict';
return angular.module('myApp.controllers', ['myApp.services'])
.controller('IndexCtrl', ['$scope', 'googleService', function ($scope, googleService) {
$scope.login = function () {
googleService.login().then(function (data) {
// do something with returned data
console.log(data.email);
@dskaggs
dskaggs / gist:3788338
Created September 26, 2012 14:21
Using caching to improve your ColdFusion application's performance

As you write more and larger ColdFusion applications, you will start looking for ways to improve the performance of your applications. There are many ways to do this but one of the easiest is to use ColdFusion's caching mechanisms to reduce the amount of work your application has to do over and over. Caching simply refers to the idea that you create a piece of content or data once and hold it in application memory for some period of time. During that time frame, any part of your application that needs that content or data uses the copy that was previously generated rather than regenerating it.

ColdFusion has several different caching mechanisms built in, but they generally fall into two main categories--programmatic caching and application server caching.

##Programmmatic Caching This type of caching is controlled by your application code. You decide which parts of your application would benefit from being cached and use CFML tags and attributes to determine what content is cached and how long your applicati

@clarle
clarle / app.js
Created July 26, 2012 07:35
Short tutorial on how to use Express and node-mysql
// Module dependencies
var express = require('express'),
mysql = require('mysql');
// Application initialization
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
@mshafrir
mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@jsteenkamp
jsteenkamp / upload.cfc
Created July 30, 2011 21:43
ColdFusion code for Plupload file uploading including chunked transfers
<cfcomponent>
<cffunction name="upload" access="remote" returntype="struct" returnformat="json" output="false">
<cfscript>
var uploadDir = expandPath('.') & '/uploads/'; // should be a temp directory that you clear periodically to flush orphaned files
var uploadFile = uploadDir & arguments.NAME;
var response = {'result' = arguments.NAME, 'id' = 0};
var result = {};
// if chunked append chunk number to filename for reassembly
if (structKeyExists(arguments, 'CHUNKS')){