Skip to content

Instantly share code, notes, and snippets.


Dylan Jhaveri dylanjha

  • Mux
  • San Francisco
View GitHub Profile
View sti-perf-hax.rb
class MyBase < ActiveRecord::Base
def self.compute_type(type_name)
case type_name
when "MyBase"; MyBase
when "Foo"; Foo
when "Bar"; Bar
else super
View gist:11092135
View gist:10234719
I copied this example which integrates
Then I tweaked this script: <script src="js/chessboard.js"></script>
I changed the addEvents function to only register mouse event handler for desktops because when I tested it on old android browsers, touchstart and mousedown events were both firing:
if (isTouchDevice() === true) {
boardEl.on('touchstart', '.' + CSS.square, touchstartSquare);
containerEl.on('touchstart', '.' + CSS.sparePieces + ' .' + CSS.piece,
//$(window).on('touchmove', touchmoveWindow); nad cutout
//$(window).on('touchend', touchendWindow); nad cutout
} else { // all the same mouse stuff that is in the default setup
View ticket.rb
class Ticket < ActiveRecord::Base
belongs_to :grouper
belongs_to :user
validate :user_cant_be_blacklisted, on: :confirmation
validate :user_cant_double_book, on: :confirmation
validate :grouper_cant_be_full, on: :confirmation
validate :grouper_cant_have_occurred, on: :confirmation
View reshaping_the_command_approach.rb
class Case < ActiveRecord::Base
include Eventable
has_many :tasks
concerning :Assignment do
def assign_to(new_owner:, details:)
transaction do
View grouper_interactor_example.rb
class GroupersController < ApplicationController::Base
def create
@grouper = current_member)
redirect_to home_path
xaviershay /
Last active Apr 11, 2018
Pull request feature requests

Hello Github,

Pull requests are not serving me well on large reviews. Here are some problems and suggested enhancements that would make me happy.

  • Mark comment as "resolved" (see google docs for an example). As code changes, comments get lost or made redundant, and it is not clear (to either the author or reviewers) which are still relevant and which have been addressed. Resolving a comment doesn't need to make it dissappear, but I need to be able to see "which comments have not been addressed" somehow. This feature would be the most useful to me.
  • Reply to a comment. This can be done in effect on line comments (assuming there is only one), but cannot on PR comments. Particularly with many threads, the lack of this makes a review hard to follow.
  • Explicit "approve/block" life cycle. The block is actually more important to me ... often on a PR that has been incrementally improved I want to "block" final merge of it until I get a chance to rebase/squash and generally pretty it up. The block can be over
View git-recent
# git-recent
# Call 'git fetch' and log all remote branches that have any activity
# in the past n days (default=3).
# Place this script in your PATH, chmod +x it, and git will allow you to magically do:
# $ git recent (days)
View app.js {
this.resource('post', { path: '/posts/:post_id' });
App.PostRoute = Ember.Route.extend({
model: function(params) {
return'post', params.post_id);
xaviershay / befunge_compiler_prototype.rb
Created Jul 17, 2013
A very quick sketch of a befunge compiler.
View befunge_compiler_prototype.rb
class ValueObject < Struct
def self.[](*args)
if args.length > 0
def [](*args)