Skip to content

Instantly share code, notes, and snippets.

View mbriggs's full-sized avatar

Matt Briggs mbriggs

View GitHub Profile
Routes.define({
jobs: {
module: App.Job,
search: {
modules: [App.Job.SearchList, App.Job.FiltersSidebar]
},
create: {
modules: [App.Job.CreateForm, App.Job.InfoSidebar]
@mbriggs
mbriggs / gist:4255089
Created December 11, 2012 01:49
apps I use every day
iStat - monitor resource consumption
LittleSnapper - scrapbook for inspiration / nice screencaps
KeyRemap4MacBook - ctrl / fn need swapping, and up key repeat speed past what the control panel allows
Caffeine - keep machine awake
Fantastical - natural language calendar
Bartender - keep menubar sane
BetterTouchTool - map gaming mouse buttons to various things
Shimo - Nice VPN tool, supports many networks
DragonDrop - wiggle the mouse when dragging to create a temporary "dock"
Alfred - best app launcher on any os ever
(add-hook 'magit-log-edit-mode-hook 'insert-ticket-number-from-branch-name)
(defun insert-ticket-number-from-branch-name ()
(erase-buffer)
(evil-insert-state)
(let* ((current-branch (car (vc-git-branches)))
(ticket-number (replace-regexp-in-string "[0-9]+\\(_.*\\)$" ""
current-branch nil nil 1)))
(when (string-match "^[0-9]" current-branch)
(insert (concat "#" ticket-number ": ")))))
@mbriggs
mbriggs / gist:4429104
Created January 1, 2013 18:17
Bruce Tognazzini - 2005

First of all, i grew up on mac os 6 and 7, and I would like to thank you for contributing to one of the most enjoyable experiences i have ever had from a computer. to this day, with dozen other operating systems under my belt, i still look back fondly to my days on os 7.

the unix editor vi flys in the face of every usability guideline on the planet. yet it has enjoyed widespread use and popularity, even amoung people who arnt forced to learn it. wouldnt new users want something that doesnt send their brain into tailspins when they operate it? wouldnt we get a natural selection effect, where given the

@mbriggs
mbriggs / gist:4963698
Created February 15, 2013 21:29
terrible code with promises
var db = {
insertUser: function(email){
var result = defer();
client.query("INSERT INTO users(email, name) VALUES($1, $1)", [email], result.resolve);
return result.promise;
},
findUser: function(email){
it("adds to the data in the custom handler", function(done){
repo.getSomething().then(function(data){
expect(data.success).toBe(true);
expect(data.foo).toBe('bar');
done();
});
});
# in a simple case, I wish rails worked like this
messages = order.validate # returns errors array
if messages.empty?
order.save!
render 'show'
else
flash[:errors] = messages
render 'edit'
@mbriggs
mbriggs / details.js
Created April 11, 2013 14:53
marionettte tabbed-view container
var PrescriptionActions = TabbedView.extend({
tabs: {
"Prescription Info": DetailsView,
"Refill": RefillView,
"Renew": DetailsView
}
});

Sometimes, It's OK To Leave A Mess

Recently, we watched the excellent lunch and learn video from [Hashrocket][hashrocket], where [Sandi Metz][metz] [talks about test design][test-design]. While the whole video is worth watching, one thing that stood out to me was her term "Omega Mess".

Sometimes, there is something that you do based on experience, but it isn't formulated as a conscious thought. While very valuable, these understandings can become much more valuable when you are forced to explain them to someone else, because it stops being instinctual and becomes conscious.

The first time I heard someone refer to this concept was pairing with [Victor Savkin][savkin], where he referred to parts of the code as his "Dirty little secrets". While this is still my favourite name for the concept, I think Sandi's name of Omega Mess, meaning a mess that is at the end of everything, is far more apt, so I have used it ever since.

The Boyscout Rule

@mbriggs
mbriggs / gist:5526196
Created May 6, 2013 16:23
functional api
# I think having the "functional" api to the rest of the system is the important part, if those functions happen to use objects, thats fine to me.
# in this case we are treating the "object" as a way to partially apply all the private functions to share the same arg
# IMO the only "danger" with using objects in this type of place is that you are going to hesitate if you want to add functions
# which do not use "all_events". In this case I think its probably fine, since "ReconcilesEvents" implies working on the full collection
class ReconcilesEvents
def self.tasks_that_have_not_ended(all_events)
new(all_events).unended_tasks
end