Skip to content

Instantly share code, notes, and snippets.

View aroman's full-sized avatar
👋
hiring!

Avi Romanoff aroman

👋
hiring!
View GitHub Profile
@aroman
aroman / vimrc 1-23-12
Created January 24, 2012 01:23
aroman's vimrc
scriptencoding utf-8
" ^^ Please leave the above line at the start of the file.
" Default configuration file for Vim
" $Header: /var/cvsroot/gentoo-x86/app-editors/vim-core/files/vimrc-r3,v 1.1 2006/03/25 20:26:27 genstef Exp $
" Written by Aron Griffis <agriffis@gentoo.org>
" Modified by Ryan Phillips <rphillips@gentoo.org>
" Modified some more by Ciaran McCreesh <ciaranm@gentoo.org>
" Added Redhat's vimrc info by Seemant Kulleen <seemant@gentoo.org>
by_course: (token, cb) ->
to_return = []
Course
.where('owner', token.username)
.run (err, courses) ->
processed = 0
courses.forEach (course) ->
Assignment
.where('course_id', course._id)
Course
.where('owner', token.username)
.run (err, courses) ->
Assignment
.where('course_id')
.in(_.pluck(courses, "_id"))
.run (err, assignments) ->
cb _.groupBy(assignments, "course_id")
@aroman
aroman / EditableMixin
Created April 6, 2012 16:38
*Ehm*, this shit's got to go.
var EditableMixin = {
useCriterion: function () {
if (this.criterion) {
return this.criterion;
} else {
return "";
}
},
Dothings.update
{
foo: bar
baz: qux
}
{
qux: bar
baz: foo
}
@aroman
aroman / gist:2369754
Created April 12, 2012 18:12
# of models with and without given attribute
var done_and_unarchived = this.model.get('assignments').where({
done: true,
archived: false
}).length;
<script id="conversation-stub-template" type="text/x-handlebars-template">
<td>Unread count: {{unread}}</td>
<td>{{last_message}}</td>
</script>
conversation_stub_template = Handlebars.compile($("#conversation-stub-template").html());
ConversationStubView = Backbone.View.extend({
tagName: 'tr',
@aroman
aroman / gist:2675700
Created May 13, 2012 03:33
Case in point
Handlebars.registerHelper('course_options', function (course_id) {
str = "";
_.each(courses.pluck("_id"), function (current_id) {
str += "<option";
if (current_id === course_id) {
str += " selected";
}
str += ">" + courses.get(current_id).get('title') + "</option>\n";
});
@aroman
aroman / gist:2676331
Created May 13, 2012 03:39
Actual case in point
Handlebars.registerHelper('course_options', function (course_id) {
str = "";
_.each(courses.pluck("_id"), function (current_id) {
str += "<option";
if (current_id === course_id) {
str += " selected";
}
str += ' value="' +
current_id +
@aroman
aroman / gist:2690688
Created May 13, 2012 23:00
Assignment move strategy
update_assignment: (token, assignment, cb) ->
# Pull the assignment from the current course,
# push it onto the new one, save it,
# and finally update the assignment fields.
Course.update {
owner: token.username
assignments: assignment._id
},
{
$pull: {assignments: assignment._id}