Margaret Scott
Friday, October 3, 2014
Friday, October 18, 2013
Lolcommits at Play
A continuation of my previous post, Lolcommits at Work...
Now you're ready to commit! Once you've pushed, you should have a shiny new lolcommits folder in your repository's root and a lovely commit message linking to your gif, like this one!
Sharing is caring. Why stash all these awesome Lolcommits away in your hard drive, never to see the light of day? Let's upload our gifs to the GitHub repo and include links to them in our commit messages!
(Okay, maybe not for shared work repositories, but personal projects? Heck yeah!)
Perusing the issues page on Lolcommits, I came across much of the code to do this. Here's how:
Perusing the issues page on Lolcommits, I came across much of the code to do this. Here's how:
Your post-commit file
You could throw all the code into the post-commit file itself, but that would get too complicated when the day comes that I want to execute multiple scripts following a git commit. Instead, I'll just call append-lol.rb. Yes, that's right, you can write git hooks in Ruby!
You don't need lines 2 and 3 if you're not using Ruby Version Manager. If you are using RVM, make sure you use something you actually have installed.
On line 4, put in the path to your repo's hooks folder /append-lols.rb.
You could throw all the code into the post-commit file itself, but that would get too complicated when the day comes that I want to execute multiple scripts following a git commit. Instead, I'll just call append-lol.rb. Yes, that's right, you can write git hooks in Ruby!
You don't need lines 2 and 3 if you're not using Ruby Version Manager. If you are using RVM, make sure you use something you actually have installed.
On line 4, put in the path to your repo's hooks folder /append-lols.rb.
append-lols.rb
Finally, you can use this append-lols.rb file as is. Save it in your repo's .git/hooks folder. I've commented extensively so that you may follow along.
Finally, you can use this append-lols.rb file as is. Save it in your repo's .git/hooks folder. I've commented extensively so that you may follow along.
Now you're ready to commit! Once you've pushed, you should have a shiny new lolcommits folder in your repository's root and a lovely commit message linking to your gif, like this one!
Lolcommits at Work
Last week, I gave a presentation on git hooks for my company's Hack Day. It was well received so I thought I'd do a little write up for anyone who would like to implement them in their development project.
What is a git hook?
An additional script you can execute when you git commit. Find out more.
Lolcommits
The shiny happy people of Visible Measures!
What is a git hook?
An additional script you can execute when you git commit. Find out more.
Lolcommits
Lolcommits is a nifty little ruby gem by Matthew Rothenberg. With Lolcommits, every time you git commit your built-in webcam will take and save a picture! In the top right of this picture will be the first bit of the commit's Secure Hash Algorithm and in the bottom will be your commit message. All the install and usage instructions for Lolcommits can be found on Github.
The git hook
Running lolcommits --enable from the terminal, whilst inside a git repository will create a file called post-commit in the hidden subdirectory .git/hooks. That file contains:
The git hook
Running lolcommits --enable from the terminal, whilst inside a git repository will create a file called post-commit in the hidden subdirectory .git/hooks. That file contains:
With this file in place, every time you git commit, the lolcommits --capture command will also run. Modify the post-commit file for fun gifs.
3 is the length of time, in seconds, that your camera will capture images. "Fork," forks the process so as not to tie up your terminal.
Timelapse
All your images are stored as jpgs (or gifs) in ~/.lolcommits/<your-repository-name>. You can create a timelapse of jpegs easily if you cd into that directory and run
convert `find . -type f -name "*.jpg" -print0 | xargs -0 ls -tlr | awk '{print $9}'` timelapse.mpeg
I can't wait to document my career at Visible Measures with a super-awesome timelapse!
3 is the length of time, in seconds, that your camera will capture images. "Fork," forks the process so as not to tie up your terminal.
Timelapse
All your images are stored as jpgs (or gifs) in ~/.lolcommits/<your-repository-name>. You can create a timelapse of jpegs easily if you cd into that directory and run
convert `find . -type f -name "*.jpg" -print0 | xargs -0 ls -tlr | awk '{print $9}'` timelapse.mpeg
I can't wait to document my career at Visible Measures with a super-awesome timelapse!
Tuesday, August 6, 2013
Adding all the Admin functionality with the Active Admin gem and fixing problems with Active Admin
After toiling on admin screens for a few hours I learned a valuable lesson... there's a gem for that! The Active Admin gem gives you an entire framework for adding those screens. There's already great documentation and a Rails Cast on this.
For people like me, who didn't realize this until they were well into their app development but still want the functionality (trust me it looks sleek and easy to maintain) I recommend this blog which also points out how to implement the framework when you already have your authentication system up and running.
From there, at least at the time of this post, you'll need to make several fixes.
(1) In your routes.rb file, move your root to: "whatever#whatever' line to line 2. So that it's inside the app class but not the Active Admin class.
If you run rake routes you'll notice that Active Admin added another route path to dashboard#index.
(2) In your gem file, specify an older version of jquery-rails by inserting:
Active Admin is dependent on something called jquery-ui which is not included in the more recent jquery-rails gem.
(3) In the Active Admin Initializer (config>initializers add:
(4) Notice that installing Active Admin created a migration to add Admin comments. Delete the migration file or, if you want them, rake db:migrate.
And that's all folks. Make sure to restart your server.
By the way, I'm using this over at https://github.com/eudaimonious/gating_app.git
Happy coding!
For people like me, who didn't realize this until they were well into their app development but still want the functionality (trust me it looks sleek and easy to maintain) I recommend this blog which also points out how to implement the framework when you already have your authentication system up and running.
From there, at least at the time of this post, you'll need to make several fixes.
(1) In your routes.rb file, move your root to: "whatever#whatever' line to line 2. So that it's inside the app class but not the Active Admin class.
If you run rake routes you'll notice that Active Admin added another route path to dashboard#index.
(2) In your gem file, specify an older version of jquery-rails by inserting:
gem "jquery-rails", "2.3.0"Then run
bundle update jquery-rails
Active Admin is dependent on something called jquery-ui which is not included in the more recent jquery-rails gem.
(3) In the Active Admin Initializer (config>initializers add:
config.logout_link_method = :deleteand update:
config.logout_link_path = :destroy_admin_user_session_pathto whatever your user model is. So for me, it's:
config.logout_link_path = :destroy_user_session_path
(4) Notice that installing Active Admin created a migration to add Admin comments. Delete the migration file or, if you want them, rake db:migrate.
And that's all folks. Make sure to restart your server.
By the way, I'm using this over at https://github.com/eudaimonious/gating_app.git
Happy coding!
Wednesday, July 31, 2013
Tuesday, July 30, 2013
Avatars for everyone!
I was inspired to finally learn vector graphics last night and here are the results! I posted my new avatar on Facebook and almost immediately received two inquiries from friends... one a CEO wanting avatars for all of his employees, and another from a restaurant owner who wants to put the avatar on her smart car! How freaking awesome is that?
I think I'll start a pay what you want system... any takers?
Algorithms
Subscribe to:
Posts (Atom)