Skip to content

Instantly share code, notes, and snippets.

View nickserv's full-sized avatar

Nicky McCurdy nickserv

View GitHub Profile
@nickserv
nickserv / pry_runtime_invocation_tutorial.md
Last active December 12, 2015 02:38
A simple tutorial for invoking pry (an awesome REPL for Ruby) at runtime
  1. Install pry.
gem install pry
  1. Require pry at the top of whatever Ruby file to want to launch it from.
require 'pry'
@nickserv
nickserv / update.sh
Created February 28, 2013 07:54
A simple bash script that updates Bower packages and Bootswatch themes for a website
#!/bin/bash
# Updates Bower packages and reinstalls latest versions of Bootswatch themes
function bootswatch {
pushd components/bootstrap.css/css > /dev/null
for theme in $*; do
echo "Downloading $theme theme"
curl http://bootswatch.com/$theme/bootstrap.css -so bootstrap-$theme.css
curl http://bootswatch.com/$theme/bootstrap.min.css -so bootstrap-$theme.min.css
done
@nickserv
nickserv / fix_dropbox.md
Last active December 15, 2015 02:49
Fix Dropbox file watching on Linux
  1. Add this to the end of /etc/sysctl.conf (as root):
# Fix Dropbox
fs.inotify.max_user_watches = 100000
  1. Restart Dropbox.
@nickserv
nickserv / micro_fizzbuzz.rb
Created May 30, 2013 06:32
A simple FizzBuzz implementation in one line of Ruby
(1..100).each { |i| puts((i%3==0 ? "Fizz" : "") + (i%5==0 ? "Buzz" : "") + ((i%3!=0 and i%5!=0) ? i.to_s : "")) }
@nickserv
nickserv / jquery_event_binding.js
Created June 25, 2013 14:19
jQuery event binding with on/off
// see http://blog.jquery.com/2011/11/03/jquery-1-7-released/
$('a').bind('click', myHandler);
$('a').on('click', myHandler);
$('form').bind('submit', { val: 42 }, fn);
$('form').on('submit', { val: 42 }, fn);
$(window).unbind('scroll.myPlugin');
$(window).off('scroll.myPlugin');
@nickserv
nickserv / data_format_examples.md
Last active December 19, 2015 03:19
Data format examples

Original Data in Ruby

{
  "a" => 1,
  "b" => 2,
  "c" => 3,
  "d" => [1, 2, 3]
}
@nickserv
nickserv / readme_badges.md
Last active December 19, 2015 18:09
Recommended readme badge services for Ruby projects on GitHub
require 'octokit'
require 'colorize'
def create_logged_in_client
puts 'Logging into GitHub. Don\'t worry, I won\'t save your credentials.'
print 'GitHub username: '
username = $stdin.gets.strip
print 'GitHub password: '
password = begin
`stty -echo` rescue nil
@nickserv
nickserv / gist:6063968
Last active December 20, 2015 03:29
Good practices for git

Good practices for git

Commits

  • Write great commit messages. Your commit messages should start with a short description on one line, capitalized and in the present tense.
  • Like your software, your commits should be cohesive. Try to keep the contents of a commit related, unless you need to generate/edit a lot of files for a good, specific reason. If you suddenly realize that you want to commit something unrelated to your original uncommited changes, you should probably use git stash to save away unrelated changes before you commit.
  • Commit early. Commit often. If you wait too long to commit, the scope of your commits may be harder for others to understand, and you will run into merge conflicts more frequently.
  • Be careful with --patch. It can be very useful, though it also makes it easier to commit portions of your changes that you haven't tested without the rest of your changes.
  • __Avoid committing binary fi