ruby Ruby on Rails: autotest color hacks ruby tdd testing tools workarounds workflow
by bseanvt
3 comments
Color Output with Test:Unit, AutoTest and Ruby 1.9
If you are testing using Test:Unit (rather than RSpec) and you’re using Ruby 1.9.* colorized output of your tests using Autotest will not be immediately available. Since, 1.9 comes with mini test the test/unit/ui/console/testrunner.rb script is not loaded and not available and will break your tests.
The solution is to require Test:Unit version 2.0.0 in your Gemfile, require the testrunner.rb script in test/test_helper.rb and reopen and implement the guess_color_availability method.
Then you can just run the autotest command (or bundle exec autotest) from your project directory. When you save a file your tests will be run for the file that has been changed and the results will be fully colorized!
Git: branching commit Git mistakes recovery reflog workflow
by bseanvt
leave a comment
How to Recover a Mistakenly Deleted Branch
Workflow
git checkout -b _new_branch_name
# do some work and commit changed
git checkout master
git branch -d _new_branch_name
# doh... i meant to merge first
Fortunately, you can easily recover from this mistake.
git reflog
395b1ea HEAD@{0}: checkout: moving from _master_cleanup_akismet to _master_cleanup
bd7df04 HEAD@{1}: commit: spam handling using akismet for form submissions on contact_submission and applicant models
395b1ea HEAD@{2}: checkout: moving from _master_cleanup to _master_cleanup_akismet
395b1ea HEAD@{3}: commit: cleaning up and adding some basic features
a828ef3 HEAD@{4}: checkout: moving from master to _master_cleanup
Should show you a list of commits across all branches in desc chronological order.
To merge the branch you just deleted you can give merge the sha.
git merge bd7df04
Which would match the commit at HEAD@{1}
Git Feature Branch Naming Strategy
There are only two hard things in Computer Science: cache invalidation and naming things.
– Phil Karlton
Typically, we have three main branches at any given time in a project lifecycle.
master, development and staging.
Master is production ready code, development is actively being worked on and staging is pre-flight testing before deploying master.
Features are branched off of development and use underscores to indicate distance from originating branch. For instance
_development_users __development_users_reset_password
indicates that __development_users_reset_password branched off of _development_users branch.
___development_users_reset_password_experiment
(3 underscores away) would indicate that I was experimenting with a branch off of development users reset password branch.
This provides a nice visual hierarchy when running git branch from the command line. It’s also helpful when you have multiple features being worked on by several people and you want to know where these branches are in relation to each other without needing to ask anyone. Here is a more complex example that illustrates the usefulness in using underscores in naming feature branches
__development_people_importing_csv * __development_people_importing_xml __development_users_password_reset _development_people_importing _development_users development master staging
Git: development Git gitignore productivity rm source control workflow
by bseanvt
leave a comment
Git Untrack Already Tracked Files
To remove files that are currently being tracked by git, you have to remove them from the “cache”. Note, doing this will NOT delete the file on your local machine. It will still be there but not be tracked.
git rm -r --cached supersecretpasswords.txt
You then need to add the file to the .gitignore file in the root of the project so that it isn’t tracked again on your next commit.
vim .gitignore supersecretpasswords.txt
.gitignore files are tracked so remember to check in these changes.
git commit -am'my super secret passwords are safe!'
If you want to completely delete the file, on your local machine and from git
git rm supersecretpasswords.txt
If you’re working with a directory remember to add the -r flag for recursive removal!
Git: branching errors fixes Git how to invalid workflow
by bseanvt
leave a comment
Git: How to Delete a Branch with an Invalid Name
If you’ve named a branch beginning with two dashes “–”, you’re sort of in trouble because git interprets your branch name as a switch/flag. You can skip switches all together
by supplying two dashes before your branch name
git branch -d -- --index_for_suppliers
and your branch will be deleted!
Git: commit Git hard head reset source control workflow
by bseanvt
leave a comment
How to Remove Your Last Git Commit
Remove your last commit (if you haven’t pushed yet)
git reset --hard HEAD~1
To see changes that have been committed and their position in HEAD
git reflog
And to undo your previous reset and advance the cursor to the reference immediately behind the current state
git reset --hard HEAD@{1}
If you have already pushed you can
git revert HEAD
which will reverse your last commit by creating a new commit
Programming: app command line launch photoshop productivity psd terminal workflow
by bseanvt
leave a comment
Launch Photoshop (Or Any App) From The Command Line on Mac OS X
I often find myself coding with the terminal open. Cding around a web app project I usually end up at some point launching Photoshop. Either to touch up or work on a psd, png, jpg …etc. I fire up Photoshop and then navigate to the app’s public directory, where the site images are kept. Then begins the hunt in finder for the image. This takes some time and if I’m already at the command line it would be nice to launch Photoshop with the exact file I want with a single command! To accomplish this just make an alias in your bash profile like so…
#fire up your text editor and edit your profile vim ~/.bash_profile #create the alias command alias psd="open -a /Applications/Adobe\ Photoshop\ Elements\ 3/Photoshop\ Elements\ 3.app"
You need to fire up a new terminal instance before this setting will take place. CMD+N.
Then from the command line type
psd my-image.psd
Note, I didn’t use “ps” as the alias because this is already taken by the system. Also the path to the application may be different on your system. Make sure you use the correct path or you may have an error like
LSOpenFromURLSpec() failed with error -10827 for the file...
Programming: branch checkout Git master merge workflow
by bseanvt
leave a comment
Very Basic Git Workflow
Very, very basic git workflow
git pull git branch dev_branch git checkout dev_branch #make some changes git checkout master git merge dev_branch git branch -d branch_to_delete git push


