Skip to content

Instantly share code, notes, and snippets.

View rheajt's full-sized avatar
🏠
Working from home

jordan rhea rheajt

🏠
Working from home
View GitHub Profile
@rheajt
rheajt / angularFire.js
Created November 20, 2015 22:09
Angular Problems!
app.factory('Auth', ['$firebaseAuth', 'FBURL',
function($firebaseAuth, FBURL) {
var ref = new Firebase(FBURL);
return $firebaseAuth(ref);
}]);
app.factory('User', ['FBURL', '$firebaseObject',
function(FBURL, $firebaseObject) {
var ref = new Firebase(FBURL + '/users');
var userData = {};
@rheajt
rheajt / add-new.js
Created December 8, 2015 06:56
jquery add new input box with click
//Add new section click
$('#sections').on('click', 'button',function() {
var sectionNum = $('#sections').children().length + 1;
// Create the snippet of html for each section
var html = '<div class="block">';
html += '<div class="inline form-group">';
html += '<label>Section ' + sectionNum + '</label>';
html += '<input class="lesson-section" id="section' + sectionNum + '">';
html += '</div>';
html += '<div class="inline form-group">';
function drawer(price, cash, cid) {
var totalCid = cid.map(function(each) {return each[1];})
.reduce(function(a, b) {return a + b;});
var inDrawer = cid.map(function(each) {return [each[0], getCurrencyTotals(each)];});
var totalDue = cash - price;
if(totalDue > totalCid) {
@rheajt
rheajt / AVGCOMPLETES.gs
Created January 18, 2016 13:02
custom function to create a numerical average from text fields in google sheets
function AVGCOMPLETES(arr) {
//declare the array that will be used to get the average
//push 100 to the array if the field is 'complete' and 0 to the array if the field is 'incomplete'
var averageArray = [];
for(i = 0; i < arr[0].length; i++) {
if(typeof arr[0][i] === 'string') {
if(arr[0][i].toLowerCase() === 'complete') {
averageArray.push(100);
} else if(arr[0][i].toLowerCase() === 'incomplete') {
averageArray.push(50);
@rheajt
rheajt / angular-analytics.js
Created January 19, 2016 07:38
google analytics with angularjs
/* Comment out the last line of the analytics code that is given by Google.
* This code triggers on page views in angular
*/
app.run(['$rootScope', '$location', '$window', function($rootScope, $location, $window) {
$rootScope.$on('$routeChangeSuccess', function() {
$window.ga('send', 'pageview', {page: $location.url()});
});
}]);
@rheajt
rheajt / readme.md
Created January 21, 2016 10:13
scotch.io tutorial about using gulp.js

#Scotch.io Tutorial

Original article found here...

The gulp api is incredibly light containing 4 top level functions. They are

  1. gulp.task
  2. gulp.src
  3. gulp.dest
  4. gulp.watch
@rheajt
rheajt / getTags.gs
Created February 24, 2016 07:35
parent-teacher conference helper
function getAvailableTags() {
var data = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Gradesheet').getDataRange().getValues();
var headers = 1; // number of header rows to skip at top
var studentNumber = 0; // column # (0-based) containing tag
var firstName = 1;
var lastName = 2;
var availableTags = [];
for (var row = headers; row < data.length; row++) {
@rheajt
rheajt / gulpfile.js
Created March 2, 2016 15:37
scotch.io tutorial on using gulp
// basic gulpfile.js based on the scotch.io tutorial
var gulp = require('gulp'),
gulpUtil = require('gulp-util'),
jshint = require('gulp-jshint'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify');
@rheajt
rheajt / Code.gs
Last active November 24, 2016 07:44
/**
* Return, rewrite, regrade
*
* @param {number} The original grade
* @param {number} The re-graded assignment
* @param {number} The percentage of the regraded assignment to count
* @return The curved grade
* @customfunction
*/
function REGRADEDCURVE(original, newGrade, percentage) {
/**
* Gives you the top 4 values from a range
* @param {array} range of numbers to get the top 4 from
* @param {number} number of values to return
* @return top 4
* @customfunction
*/
function GETTOP(gradeRange, topNumber) {
var allGrades = gradeRange.reduce(function(a,b) {
// flatten the multidimensional array into a single array