Skip to content

Instantly share code, notes, and snippets.

@zwily
zwily / emoji.coffee
Created February 26, 2013 22:01
emoji (github-flavored) for limechat + limescripts
##
# replaces :blah: with an image with the appropriate emoji
all_emojis = [
'+1', '-1', '100', '1234', '8ball', 'a', 'ab', 'abc', 'abcd', 'accept',
'aerial_tramway', 'airplane', 'alarm_clock', 'alien', 'ambulance', 'anchor',
'angel', 'anger', 'angry', 'anguished', 'ant', 'apple', 'aquarius', 'aries',
'arrow_backward', 'arrow_double_down', 'arrow_double_up', 'arrow_down',
'arrow_down_small', 'arrow_forward', 'arrow_heading_down',
'arrow_heading_up', 'arrow_left', 'arrow_lower_left', 'arrow_lower_right',
var HomeUI = {
imageLoadCounter:1,
delayTimer:null,
animationTimer:null,
timerCounter:0,
currentAnimation:null,
animating:false,
popUpTimer:null,
NUM_IMAGES_TO_LOAD:4,
POP_UP_DELAY:3000,
@getify
getify / 1.js
Last active December 14, 2015 18:38
requestEachAnimationFrame hopeful-fill.
(function(){
var
rAF = (window.requestAnimationFrame || window.msRequestAnimationFrame ||
window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame ||
window.oRequestAnimationFrame),
cAF = (window.cancelAnimationFrame ||
window.msCancelAnimationFrame || window.msCancelRequestAnimationFrame ||
window.mozCancelAnimationFrame || window.mozCancelRequestAnimationFrame ||
window.webkitCancelAnimationFrame || window.webkitCancelRequestAnimationFrame ||
window.oCancelAnimationFrame || window.oCancelRequestAnimationFrame),
@cmatheson
cmatheson / generate_big_quiz.rb
Created March 13, 2013 20:53
this is good for testing Quiz#statistics performance
COURSE_ID = 5 # replace this with id of course with many (>=500) students
# generating a large course is left as an exercise to the reader
course = Course.find(COURSE_ID)
# generate quiz
q = course.quizzes.create! :title => "Big Quiz"
eval(File.read 'quiz_questions.txt').each_with_index do |(question, as), i|
answers = as.map.with_index { |a, j|
@cmatheson
cmatheson / quiz_questions.txt
Created March 13, 2013 20:55
just some sample quiz questions scraped from the interwebs for testing quiz statistics
[
["The main function of myelin is to",
["form a protective coating over nerve axons.",
"affect the speed of nerve impulses.",
"block the reception of acetylcholine.",
"aid a nerve's receptivity to neurotransmitters by increasing the number of receptor sites available."]],
["The part of the nerve cell specialized for conducting information is the",
["axon.",
"cell body.",
@aaronshaf
aaronshaf / canvas-development.md
Last active December 21, 2015 12:59
Canvas Development

"to get the selenium errors locally, you have to use USE_OPTIMIZED_JS=true bundle exec spec spec/selenium/path_to_spec.rb" - stanley

?debug_js=1

bake canvas:compile_assets
def mvim
edit_interactively 'mvim -f -c "set filetype=ruby"'
end
class Object
def send_chain(meths)
result = self
meths.each do |m|
return nil if result == nil
if result.respond_to?(m)
@cmatheson
cmatheson / toggle-class-cache.sh
Last active December 22, 2015 08:09
toggle rails class caching in canvas
function toggle-class-cache() {
cfg=config/environments/development-local.rb
if grep -q config.cache_classes $cfg; then
sed -i '
/config.cache_classes/ s/true/false/
t
s/false/true/' \
config/environments/development-local.rb
else
echo "config.cache_classes = false" > $cfg
N_ASSIGNMENTS=100
N_USERS=500
begin
account = Account.default
account.transaction do
course = account.courses.create! name: "Big Gradebook"
e = course.enroll_teacher(User.find(1))
N_ASSIGNMENTS=100
N_USERS=500
def grade_submission_sql_inserts(assignment,student,grade)
"(#{assignment.id}, #{student.id}, #{grade}, true, 'graded', '#{Time.zone.now.iso8601}')"
end
def grade_submission_sql(assignments,students)
students_sql = assignments.map do |assignment|
students.map do |student|