Skip to content

Instantly share code, notes, and snippets.

View jasonswett's full-sized avatar

Jason Swett jasonswett

View GitHub Profile
class Stylist < ActiveRecord::Base
include ActionView::Helpers::NumberHelper
scope :active, -> { where(active: true) }
scope :inactive, -> { where(active: false) }
scope :with_active_salon, -> { joins(:salon).merge(Salon.active) }
scope :non_receptionist, -> {
joins('LEFT JOIN user_role ON user_role.user_id = stylist.user_id')
.joins('LEFT JOIN role ON user_role.role_id = role.id')
.where('role.code != ? OR role.code IS NULL', 'RECEPTIONIST')
gem_group :development, :test do
gem 'pg'
gem 'pry'
gem 'devise'
gem 'rspec-rails'
gem 'factory_bot_rails'
gem 'capybara'
gem 'selenium-webdriver'
gem 'chromedriver-helper'
require 'open-uri'
require 'pry'
class Document
DOT_PADDING = 3
def initialize(text)
@words = text.gsub(/-/, ' ').split
end
[
{
name: 'Hamburger',
price: 10
},
{
name: 'Cheeseburger',
price: 11
},
{
# Generated on 2014-11-05 using generator-angular 0.9.8
'use strict'
# # Globbing
# for performance reasons we're only matching one level down:
# 'test/spec/{,*/}*.js'
# use this if you want to recursively match all subfolders:
# 'test/spec/**/*.js'
module.exports = (grunt) ->
# Load grunt tasks automatically
# Generated on 2014-11-05 using generator-angular 0.9.8
'use strict'
# # Globbing
# for performance reasons we're only matching one level down:
# 'test/spec/{,*/}*.js'
# use this if you want to recursively match all subfolders:
# 'test/spec/**/*.js'
module.exports = (grunt) ->
# Load grunt tasks automatically
gulp.task('test', function() {
server.listen(3000);
return gulp.src('spec/test.js')
.pipe(jasmine())
.on('end', function () {
server.close();
exit();
});
});
gulp.task('start-server', function() {
return server.listen(3000);
});
gulp.task('jasmine', function() {
return gulp.src('spec/test.js')
.pipe(jasmine());
});
gulp.task('test', ['start-server', 'jasmine'], function() {
this.lunchHub = angular.module('lunchHub', []);
this.lunchHub.config([
'$routeProvider', function($routeProvider) {
return $routeProvider.when('/addresses', {
templateUrl: '../templates/addresses/index.html',
controller: 'AddressIndexCtrl'
}).when('/groups', {
templateUrl: '../templates/groups/index.html',
@jasonswett
jasonswett / appointment.rb
Created November 24, 2013 18:25
A fat model
class Appointment < ActiveRecord::Base
include ActionView::Helpers::NumberHelper
default_scope :order => "start_time asc"
scope :in_date_range, lambda { |start_date, end_date| self.in_date_range(start_date, end_date) }
scope :for_day, lambda { |date| in_date_range(date, date) }
scope :for_today, lambda { for_day(Time.zone.today) }
scope :for_tomorrow, lambda { for_day(Time.zone.today + 1.day) }
scope :not_time_blocks, joins(:time_block_type).where("code = 'APPOINTMENT'")
scope :checked_out, joins(:payments)