Skip to content

Instantly share code, notes, and snippets.

View dylanjha's full-sized avatar

Dylan Jhaveri dylanjha

  • Mux
  • San Francisco
View GitHub Profile
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
.DS_Store
*.xcuserstate
*.xcuserdatad
<Your_workspace_name>.xcworkspace/xcshareddata
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
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
# MODEL
class Case < ActiveRecord::Base
include Eventable
has_many :tasks
concerning :Assignment do
def assign_to(new_owner:, details:)
transaction do
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 April 11, 2018 03:20
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
#!/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)
#
@wycats
wycats / app.js
Last active February 11, 2016 16:08
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 July 17, 2013 03:59
A very quick sketch of a befunge compiler.
class ValueObject < Struct
def self.[](*args)
if args.length > 0
new(*args)
else
new(:null)
end
end
def [](*args)