Skip to content

Instantly share code, notes, and snippets.

View michaelminter's full-sized avatar

Michael Minter michaelminter

View GitHub Profile
@chetan
chetan / yardoc_cheatsheet.md
Last active May 4, 2024 11:12
YARD cheatsheet
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@mikaelbr
mikaelbr / destructuring.js
Last active April 25, 2024 13:21
Complete collection of JavaScript destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@justinweiss
justinweiss / filterable.rb
Last active January 11, 2024 07:28
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with names based on the keys in <tt>filtering_params</tt>
# with their associated values. For example, "{ status: 'delayed' }" would call
@mattsears
mattsears / README.md
Created October 3, 2011 13:16
Todo.rb: A simple command-line TODO manager written in Ruby

Todo.rb

Todo.rb is a simple command-line tool for managing todos. It's minimal, straightforward, and you can use it with your favorite text editor.

Getting Started

Todo.rb doesn't require any third-party gems so you can copy the file anywhere and use it as long as it's executable:

@davidbella
davidbella / person.rb
Created October 10, 2013 13:37
Ruby: Dynamic meta-programming to create attr_accessor like methods on the fly
class Person
def initialize(attributes)
attributes.each do |attribute_name, attribute_value|
##### Method one #####
# Works just great, but uses something scary like eval
# self.class.class_eval {attr_accessor attribute_name}
# self.instance_variable_set("@#{attribute_name}", attribute_value)
##### Method two #####
# Manually creates methods for both getter and setter and then
@bsnape
bsnape / gist:edff869d5b7dc0b0d7c2
Last active August 29, 2023 05:15
Rubymine find & replace string hash rockets with new syntax
find:
\'(\w+)\'\s*=>
replace:
$1:
replace symbol hash rockets with new syntax
find:
@michaelminter
michaelminter / git-colors.md
Created October 1, 2012 00:35
Colors in git

Bored with just black and white in your git status? Add some colour!

Open up your global Git configuration file (it should be found in ~/.gitconfig) and enter this into it:

[color]
  ui = auto
[color "branch"]
  current = yellow reverse
  local = yellow

remote = green

@yujiberra
yujiberra / gist:1144329
Created August 13, 2011 22:44
Bash profile with color current git branch color coded by status
# Git status bash prompt
#
# In addition to printing the current working directory, this prompt will
# show a number of things if you are in a git repository:
# - The current branch you are in
# - Whether there are untracked files in the repository (there will be an
# asterisk after the branch nome if there are)
# - Whether there are any unmerged/unstaged/staged changes or if the directory
# is clean. See below for the colors that will be used, and change them if
# you'd like.
@miwahall
miwahall / jquery-bootstrap-datepicker.css
Created October 17, 2013 17:10
jQuery UI Datepicker Bootstrap 3 Style
.ui-datepicker {
background-color: #fff;
border: 1px solid #66AFE9;
border-radius: 4px;
box-shadow: 0 0 8px rgba(102,175,233,.6);
display: none;
margin-top: 4px;
padding: 10px;
width: 240px;
}