Skip to content

Instantly share code, notes, and snippets.

View simonista's full-sized avatar

Simon Williams simonista

  • Lumio
  • Austin, TX
View GitHub Profile
others_string = I18n.t('conversation_message.other_recipients', {
:one => "and 1 other",
:other => "and %{count} others"
},
:count => audience_names.length - 2)
if connection.adapter_name =~ /mysql/i
connection.execute <<-SQL
UPDATE users, conversation_participants cp
SET unread_conversations_count = unread_conversations_count + 1
WHERE users.id = cp.user_id AND #{cp_conditions}
SQL
else
User.update_all 'unread_conversations_count = unread_conversations_count + 1',
"id IN (SELECT user_id FROM conversation_participants cp WHERE #{cp_conditions})"
end
# @API
# Mark a discussion entry as read.
#
# No request fields are necessary.
#
# On success, the response will be 204 No Content with an empty body.
#
# @example_request
#
# curl 'http://<canvas>/api/v1/courses/<course_id>/discussion_topics/<topic_id>/entries/<entry_id>/read.json' \
@simonista
simonista / backlogTime.coffee
Created March 13, 2012 04:35
limescript for bip backlog timestamp translation
# remove the timestamp that bip inserts in a backlog message and set the time
# of the span element that limechat uses
bind 'line', (line) ->
# see if out message matches 'hh:mm:ss>'
html = line.innerHTML
regex = /(\d{2}:\d{2}):\d{2}&gt;/
matches = html.match regex
return unless matches
# remove that timestamp from the message
@simonista
simonista / gist:2631125
Created May 7, 2012 22:40
sql-question
select id, avatar_image_url as aiu from users order by aiu; -- works!
select id, avatar_image_url as aiu from users order by coalesce(avatar_image_url, 'zzz'); -- works!
select id, avatar_image_url as aiu from users order by coalesce(aiu, 'zzz'); -- doesn't work :(
# from app/models/submission.rb
# Current version, does not work.
[:submission_comments, :visible_submission_comments].each do |method|
alias_method "old_#{method}", method
instance_eval <<-CODE
def #{method}(options = {})
res = old_#{method}(options)
res = res.select{|sc| sc.grants_right?(@comment_limiting_user, @comment_limiting_session, :read) } if @comment_limiting_user
<object width="560" height="315"><param name="movie" value="http://www.youtube.com/v/VHRKdpR1E6Q?version=3&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/VHRKdpR1E6Q?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object>
function measureForTopicList() {
windowHeight = $(window).height();
if($after_topic_list.length > 0) {
afterTopicListTop = $after_topic_list.offset().top;
} else {
afterTopicListTop = windowHeight;
}
}
measureForTopicList();
setInterval(measureForTopicList, 2000);
# Invitations
'Account User Notification'
'Account User Registration'
'Collaboration Invitation'
'Enrollment Accepted'
'Enrollment Invitation'
'Enrollment Notification'
'Enrollment Registration'
'Group Membership Accepted'
'Group Membership Rejected'
@simonista
simonista / backlogTime.coffee
Created November 12, 2012 17:43
Some custom limescripts
# remove the timestamp that bip inserts in a backlog message and set the time
# of the span element that limechat uses
bind 'line', (line) ->
# see if out message matches 'hh:mm:ss>'
$line = $(line)
html = $line.html()
regex = /(\d{2}:\d{2}):\d{2}&gt;/
matches = html.match regex
return unless matches