Skip to content

Instantly share code, notes, and snippets.

View DanLuchi's full-sized avatar

Dan Luchi DanLuchi

View GitHub Profile
@DanLuchi
DanLuchi / gist:dd2a1d12ecd7159dcabb
Created June 8, 2015 15:26
What are you learning?
When you're a beginning, its hard to elaborate what you're learning because everything is new and what you're learning is everything. You're learning about each individual piece, how they fit together and where you fit in.
@DanLuchi
DanLuchi / pull_requests.md
Last active August 29, 2015 14:12
What I'm asking when I ask you to review my pull request

It took me a long time to warm up to pull requests. My early experiences with code review were all a tremendous waste of time: they were a bottleneck to getting things done, a forum for people to conduct their ongoing feuds or both. After years of being staunchly against pull requests, I've come around on them in the last year at Terrible Labs.

What I'm asking when I ask you to review my pull request

1. Does this make sense to you?

Start with cthe big picture and get more detailed from there.

My pull request should be trying to accomplish only one thing and that should be explained in enough detail in the commit message for you to understand, did I succeed? If something is confusing: you're not sure how this system works, or how this new piece of code fits in with other parts of the system, let me know and we can clarify it together.

@DanLuchi
DanLuchi / gist:ba1ad0e138d81223e47d
Last active August 29, 2015 14:09
Working Effectively with Legacy Code Notes
Preface
"They're writing legacy code" - from a consultant working with a new team
Fixing legacy code is like surgery: first make things better and then use that as a catalyst for change.
This book is not about clean code and not about good design
Question: I'm curious to see if knowledge of how you would architect the system now, from scratch is necessary or helpful in going about refactoring it. Do these techniques need you to have an endpoint in mind?
Chapter 1
It doesn't matter if you are adding a feature or fixing a bug, you are solving a problem.
@DanLuchi
DanLuchi / angularjs-redirecting-to-login.md
Last active August 29, 2015 14:06
Redirecting a user to login in AngularJS

Most non-trivial apps need to deal with user authentication. In this post, I'll walk through how to implement user auth in an AngularJS application and how to account for some complex scenarios that might arise.

###Step 0 - Create auth file

I find it useful to put all this code in one place, so I've created a file called auth.js.coffee in my /angular/services directory.

auth = angular.module "genericapp.auth"
@DanLuchi
DanLuchi / gist:9921389
Created April 1, 2014 19:35
Angular guardfile
# Copy ActiveSupport::Inflector.underscore to convert CamelCase angular controller names to snake_case controller spec names
class String
def underscore
self.gsub(/::/, '/').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
tr("-", "_").
downcase
end
end
@DanLuchi
DanLuchi / gist:9600114
Created March 17, 2014 14:24
uiview_helper.rb
class UIView
def controller
controller_for_view(self)
end
def controller_for_view(view)
controller = UIViewController.viewControllerForView view
if controller
controller
elsif view.superview
@DanLuchi
DanLuchi / bundles.sh
Last active December 11, 2015 04:18 — forked from mkdynamic/bundles.sh
#!/usr/bin/env bash
#
# install all of http://github.com/phuibonhoa's TM bundles (OS X only)
#
echo "Installing bundles..."
# backup dir
if [ -d ~/desktop/_tm_bundle_backups ]; then rm -rf ~/desktop/_tm_bundle_backups; fi