Skip to content

Instantly share code, notes, and snippets.

View mitchlloyd's full-sized avatar

Mitch Lloyd mitchlloyd

View GitHub Profile
s = Student.find_by(email: 'mitch.lloyd@gmail.com')
# Before
def show
if current_user.is_admin?
if params[:assignment].nil?
@assignments = Assignment.all
else
@assignments = Assignment.where(:student_id => params[:assignment][:id] )
end
else
# Before
def index
if current_user.is_student?
@assignments = current_user.assignments.order(created_at: :desc)
render "student_index"
elsif current_user.is_admin?
@current_student = params[:student]
@students = User.get_all_students
@average_grade = 0
@mitchlloyd
mitchlloyd / macbookpro-for-sale.md
Last active August 29, 2015 14:06
MacBook Pro for Sale

Early 2011 15” MacBook Pro

  • Intel 256 GB SSD Harddrive (SSDSC2CW240A3)
  • 16 GB (2x8) DDR3 1333 MHz Crucial RAM
  • AMD Radeon HD 6490M Graphics Card
  • Some minor dents on the case
  • Power supply with extension cord
  • Battery Information:
  • Cycle Count: 533
def answer_iucu_challenge(question)
case question
when /what year/: return "1988"
when /what street/: return "Main Street"
when /father\'s middle name/: return "Jonathan"
when /what city/: return "Denver"
else "blah"
end
end
import Ember from 'ember';
const { inject, computed } = Ember;
export default Ember.Controller.extend({
myService: inject.service(),
appName: computed.reads('myService.value')
});
@mitchlloyd
mitchlloyd / gist:1504102
Created December 21, 2011 01:18
Some ideas for fetching/finding with spine and callbacks.
class Model extends Spine.Model
# This one always pulls the data from the server.
@fetchAndThen: (id, callback) ->
@fetch(id: id)
@one 'refresh', (docs) -> callback(docs[0])
# This one pulls the data from the server if it isn't cached locally.
@remoteFind: (id, callback) ->
if @exists? id
callback @find(id)
@mitchlloyd
mitchlloyd / about.hbs
Last active October 2, 2015 17:26 — forked from mguterl/about.hbs
{{bd-back-button}}
@mitchlloyd
mitchlloyd / gist:5782436
Created June 14, 2013 14:45
(Blog snippet) Example of ember auto save that won't work
App.Document = DS.Model.extend
# some attributes here...
saveWhenDirty: (->
@get('store').commit() if @get('isDirty')
).property('isDirty')
@mitchlloyd
mitchlloyd / gist:5782662
Last active December 18, 2015 12:28
Simple debounce function bases on underscore's.
App.debounce = (func, wait) ->
timeout = null
->
context = this
args = arguments
immediate = true if args[0] and args[0].now
later = ->