Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jrutter's full-sized avatar

Jake Rutter jrutter

View GitHub Profile
@pmeenan
pmeenan / user-timing-rum.js
Last active January 18, 2024 23:46
Support routine for adding W3C user timing events to a site. Includes some basic polyfill support for browsers that don't support user timing or navigation timing (though the start time for non-navigation timing support could be improved with IE < 9 to use IE's custom start event).
// Support routines for automatically reporting user timing for common analytics platforms
// Currently supports Google Analytics, Boomerang and SOASTA mPulse
// In the case of boomerang, you will need to map the event names you want reported
// to timer names (for mPulse these need to be custom0, custom1, etc) using a global variable:
// rumMapping = {'aft': 'custom0'};
(function() {
var wtt = function(n, t, b) {
t = Math.round(t);
if (t >= 0 && t < 3600000) {
// Google Analytics
@aaronksaunders
aaronksaunders / app_snippet_1.js
Last active August 25, 2017 03:10
Utilizing the Queue Library from Async.js for downloading multiple assets with Appcelerator Titanium
//
// https://github.com/caolan/async
//
var async = require('async');
// this function will be called for each array element
function process(_url, _processCallback) {
// download the file
get_file(_url, function(_resp) {
@christian-bromann
christian-bromann / webdriver.js
Last active December 30, 2015 21:10
Use Webdriverjs with Sauce Labs (example)
var webdriverjs = require('../index'),
client = webdriverjs.remote({
desiredCapabilities: {
browserName: 'chrome',
version: '27',
platform: 'XP',
tags: ['examples'],
name: 'This is an example test'
},
host: 'ondemand.saucelabs.com',
@victorb
victorb / app.js
Created September 24, 2013 16:37
Easy AngularJS Directive for Google Places Autocomplete
var myApp = angular.module('myApp', []);
myApp.directive('googleplace', function() {
return {
require: 'ngModel',
link: function(scope, element, attrs, model) {
var options = {
types: [],
componentRestrictions: {}
};
@mrosati84
mrosati84 / toggleClass.html
Created October 2, 2013 10:52
Simple toggleClass implemented in AngularJS
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
.is-active {
color: red;
}
</style>
@jeffcogswell
jeffcogswell / q_example.js
Last active August 12, 2022 01:22
Here's another chaining example on using q.js. This doesn't have any error handling, as I just want to demonstrate the chaining concept. Please read the comments carefully, as I start out with a non-q example, to show the order of flow. Please post comments if there's anything that isn't clear and I'll try to revise it as needed.
// Q sample by Jeff Cogswell
/*===========
We want to call these three functions in sequence, one after the other:
First we want to call one, which initiates an ajax call. Once that
ajax call is complete, we want to call two. Once two's ajax call is
complete, we want to call three.
BUT, we don't want to just call our three functions in sequence, as this quick
@jeffjohnson9046
jeffjohnson9046 / percent-filter.js
Last active September 4, 2020 23:25
Format percentages in AngularJS
// In app.js or main.js or whatever:
// var myApp = angular.module('askchisne', ['ngSanitize', 'ngAnimate', 'ui.bootstrap', 'ui.bootstrap.tpls']);
// This filter makes the assumption that the input will be in decimal form (i.e. 17% is 0.17).
myApp.filter('percentage', ['$filter', function ($filter) {
return function (input, decimals) {
return $filter('number')(input * 100, decimals) + '%';
};
}]);
@stuwilli
stuwilli / gist:9580481
Created March 16, 2014 09:10
How to Floor, Round, Ceiling in JSTL/EL
Floor(N) -> ${N-(N%1)}
Ceiling(N) -> ${N+(1-(N%1))%1}
Round(N) -> ${N+((N%1>0.5)?(1-(N%1))%1:-(N%1))}
@stephenfeather
stephenfeather / Gruntfile.js
Last active October 2, 2015 18:18
Appcelerator Gruntjs
module.exports = function(grunt) {
require('time-grunt')(grunt);
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
CHANGELOG: '',
// add tiapp.xml changes to the repo
gitadd: {
versionBump: {
options: {
@chantastic
chantastic / on-jsx.markdown
Last active March 20, 2024 01:03
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't