Git: Rollback a commit, after making an accidental commit

January 31st, 2014

So I’m sitting here at work, and I just finished off a bunch of bugs in one of my feature branches. Yay! Now for whatever reason, I accidentally merged our staging branch into my feature branch, instead of the other way around. Crap! I hadn’t pushed though, so after a quick Google search, I came across this little gem:

git reset --hard HEAD~1

Nice! That reverted my branch to the commit before I ran the accidental merge. If you’re wondering HEAD~1 is a shorthand for the commit before head.

Hopefully this saves someone some headaches.

Syropia | How To Use Bourbon with GruntJS →

January 17th, 2014

New blog post on how to use get Bourbon to play nicely with GruntJS. 

Syropia - v4 →

January 8th, 2014

Ringing in the New Year (slightly late) with a fresh new look!

View Composer Paths in Laravel 4

November 2nd, 2013

I just ran into this, and thought I’d share a quick tip for avoiding unbound data errors when using view composers in Laravel 4.

Currently, my view hierarchy looks something like this

views
    layouts
        master.blade.php
    events
        index.blade.php 

Currently, I have my view in events/index.blade.php extending layouts/master.blade.php.

Because it’s in a folder, I need to traverse up to the master layout like so:

@extends('../layouts.master')

I’m also using a view composer to bind data to the master layout on every request. I’ve decided to simply put it in my app/filters.php file, but you can put it anywhere as long as it gets autoloaded. Here’s my view composer:

View::composer('../layouts.master', function($view) {
  $count = 0;
  if(Auth::check()){
    $count = Evnt::where('user_id', '=', Auth::user()->id)->count();
  }
  $view->with('event_count', $count);
});    

Pretty basic, we’re finding all the events that belong to the currently authenticated user and returning the count.

The gotcha, that I ran into was, I orignally passed the ../layouts.master portion without the ../, which resulted in the view composer not being fired.

The moral here, is if you are using a layout and writing views that extend the layout, you must pass the view path in your view composer just as your views extend it.

Fortunately, in case we have some crazy view directory structures going on we can pass multiple view paths through the composer.

View::composer(array('../layouts.master', 'layouts.master', '../../layouts.master'), function($view) {});    

Hopefully this helps anyone who runs in to the same problem I did. Further question? I’m @syropian on Twitter.

Hiding The OS X Spotlight Icon

October 27th, 2013 • 1 note

This is a quick post for reminding those who don’t know how to hide the spotlight icon (and disable Cmd+Space from activating it).

This I believe works from 10.6 all the way up to Mavericks.

sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search

then

killall SystemUIServer

This will not disable Spotlight indexing. I opted to not turn off indexing, because I believe Alfred utilizes it. If you don’t want indexing at all, use this command to turn it off.

sudo mdutil -a -i off