Skip to content

Instantly share code, notes, and snippets.

View simonista's full-sized avatar

Simon Williams simonista

  • Lumio
  • Austin, TX
View GitHub Profile
# ...
gem 'canvas_oauth_engine', :require => 'canvas_oauth'
# ...

How To Create A New Question Type (wip)

  • add a new file in app/models/quiz_question/ that extends QuizQuestion::Base (or another question type)
  • extend the appropriate scoring functions:
    • stats
    • total_answer_parts
    • correct_answer_parts
    • incorrect_answer_parts
  • requires_manual_scoring?
@simonista
simonista / fixme.rb
Last active February 10, 2016 19:54
Send me your cleanest version of this function
# Current gotcha's:
# - any result to be cached in the ivar (currently not true for the early return)
# - if any of the early return stuff, or if the session.key is created, we don't want to run brand_config_for_account(opts)
def active_brand_config(opts={})
@active_brand_config_cache ||= {}
return @active_brand_config_cache[opts] if @active_brand_config_cache.key?(opts)
@active_brand_config_cache[opts] = begin
return nil if !use_new_styles? || (@current_user.try(:prefers_high_contrast?) && !opts[:ignore_high_contrast_preference])
brand_config = if session.key?(:brand_config_md5)
set nocompatible
filetype off " needed to load vundle
" Manage plugins with vundle
" run :PluginInstall (or vim +PluginInstall +qall on cli)
set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#rc()
Plugin 'gmarik/vundle'
" Security
Greetings Industry Colleagues,
The School of Computing at the University of Utah will be holding our annual Senior Capstone Demonstration Wednesday, April 27th from 1:30-4:30 in Warnock Engineering Building L130 (with pizza and awards following). On this day, our seniors will show off the software projects they and their teams have completed over the past 6 months.
Judges:
The demonstration is open to all, but we ask any of you who are willing to come (or send another representative) as a judge. The judges walk around and talk to the students, and then score them on a 1-10 scale. At the end of the day, these scores are used to name the top teams for the day. Judging is a great time to really get to interact with our students and see what they are capable of.
Prizes:
We are also asking for "prize" donations from any of your companies that are able to so. We award these prizes to our students in recognition of their hard work. Prizes in the past have ranged from graphics cards to company pens. Any ty

Keybase proof

I hereby claim:

  • I am simonista on github.
  • I am simonista (https://keybase.io/simonista) on keybase.
  • I have a public key ASAXhGRLvZ_56xngoWxJTLG8Pv4uJUsGGUNc_t1NSx-j_go

To claim this, I am signing this object:

@simonista
simonista / enrollment_state.rb.diff
Created October 24, 2016 16:54
Apply this patch to the 2016-09-17 branch to avoid a problem with a migration in the 2016-10-08 branch
diff --git a/app/models/enrollment_state.rb b/app/models/enrollment_state.rb
index 66e9700..c6caf91 100644
--- a/app/models/enrollment_state.rb
+++ b/app/models/enrollment_state.rb
@@ -7,6 +7,7 @@ class EnrollmentState < ActiveRecord::Base
validates_presence_of :enrollment_id
self.primary_key = 'enrollment_id'
+ self.lock_optimistically = false
@simonista
simonista / zips.json
Created January 4, 2018 04:29
a large json file for testing json parsing
This file has been truncated, but you can view the full file.
[{ "city" : "AGAWAM", "loc" : [ -72.622739, 42.070206 ], "pop" : 15338, "state" : "MA", "_id" : "01001" }
,{ "city" : "CUSHMAN", "loc" : [ -72.51564999999999, 42.377017 ], "pop" : 36963, "state" : "MA", "_id" : "01002" }
,{ "city" : "BARRE", "loc" : [ -72.10835400000001, 42.409698 ], "pop" : 4546, "state" : "MA", "_id" : "01005" }
,{ "city" : "BELCHERTOWN", "loc" : [ -72.41095300000001, 42.275103 ], "pop" : 10579, "state" : "MA", "_id" : "01007" }
,{ "city" : "BLANDFORD", "loc" : [ -72.936114, 42.182949 ], "pop" : 1240, "state" : "MA", "_id" : "01008" }
,{ "city" : "BRIMFIELD", "loc" : [ -72.188455, 42.116543 ], "pop" : 3706, "state" : "MA", "_id" : "01010" }
,{ "city" : "CHESTER", "loc" : [ -72.988761, 42.279421 ], "pop" : 1688, "state" : "MA", "_id" : "01011" }
,{ "city" : "CHESTERFIELD", "loc" : [ -72.833309, 42.38167 ], "pop" : 177, "state" : "MA", "_id" : "01012" }
,{ "city" : "CHICOPEE", "loc" : [ -72.607962, 42.162046 ], "pop" : 23396, "state" : "MA", "_id" : "01013" }
,{ "city" : "CHICOPEE", "loc" : [
@simonista
simonista / print-express-routes.js
Created February 16, 2022 15:55
Print all the routes defined in an express app (excluding middleware)
function printRoutePaths(router, prefix) {
router.stack.forEach(function(r){
if (r.route?.path){
for (let key in r.route.methods) {
if (r.route.methods[key]) {
console.log(`${key.toUpperCase()} ${prefix}${r.route.path}`)
}
}
} else if (r.name === 'router') {
let newPrefix = r.regexp.toString().replace('/^\\', '').replace('\\/?(?=\\/|$)/i', '')
linere = /(\S+):(\d+):\s*(.*)(Setting\.get(_or_set)?\(.*(\))?)(.*)/
settingre = /['"](\S+)['"], (.*)\)/
File.readlines('settings.txt').each do |line|
if linematch = line.match(linere)
all, filename, linenumber, before, setting, or_set, after = linematch.to_a
if settingmatch = setting.match(settingre)
all, name, default = settingmatch.to_a
puts "#### #{name}\n* default: `#{default}`\n* usage: `#{before}#{setting}#{after}`\n* location: `#{filename}:#{linenumber}`\n\n"
end