Skip to content

Instantly share code, notes, and snippets.

Dylan Jhaveri dylanjha

Block or report user

Report or block dylanjha

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
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
end
end
end
View gist:11092135
.DS_Store
*.xcuserstate
*.xcuserdatad
<Your_workspace_name>.xcworkspace/xcshareddata
View gist:10234719
I copied this example http://chessboardjs.com/examples#5000 which integrates https://github.com/jhlywa/chess.js
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,
touchstartSparePiece);
//$(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
# MODEL
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 = Grouper.new(leader: current_member)
if @grouper.save
confirm_grouper_via_emails(@grouper)
enqueue_bar_assignment(@grouper)
redirect_to home_path
else
@xaviershay
xaviershay / github_requests.md
Last active Apr 11, 2018
Pull request feature requests
View github_requests.md

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
#!/bin/bash
# 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
App.Router.map(function() {
this.resource('post', { path: '/posts/:post_id' });
});
App.PostRoute = Ember.Route.extend({
model: function(params) {
return this.store.find('post', params.post_id);
}
});
@xaviershay
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
new(*args)
else
new(:null)
end
end
def [](*args)
You can’t perform that action at this time.