This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Lots of colors | |
| export PS1='\[\033[00;32m\]\u\[\033[01m\]@\[\033[00;36m\]\h\[\033[01m\]:\[\033[00;35m\]\w\[\033[00m\]\[\033[01;33m\]`git branch 2>/dev/null|cut -f2 -d\* -s`\[\033[00m\]\$ ' | |
| # Branch name colored yellow | |
| export PS1='\u@\h:\w\[\033[00m\]\[\033[01;33m\]`git branch 2>/dev/null|cut -f2 -d\* -s`\[\033[00m\]\$ ' | |
| # No colors | |
| export PS1='\u@\h:\w`git branch 2>/dev/null|cut -f2 -d\* -s`\$ ' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Signing an OAuth request | |
| # Hannes Tydén, [email protected], 2009-07-14 | |
| # Updated at 2009-09-03 to support OAuth 1.0a | |
| # This is designed to be executed in an editor evaluating expressions and outputting the result inline. | |
| # The spec: | |
| # http://oauth.net/core/1.0#signing_process | |
| # Read more: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| controller = returning(ControllerClass.new()) { |c| c.send(:assign_shortcuts, ActionController::TestRequest.new, ActionController::TestResponse.new): c.send(:initialize_current_url) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ActiveSupport::CoreExtensions::Array::Conversions | |
| def to_ordered_hash | |
| self.inject(ActiveSupport::OrderedHash.new) do |ordered_hash, (key, value)| | |
| ordered_hash[key] = value | |
| ordered_hash | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| begin; "".to_sym; rescue; $!.inspect; end # => "#<ArgumentError: interning empty string>" | |
| begin; "".intern; rescue; $!.inspect; end # => "#<ArgumentError: interning empty string>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| while true; do echo '.*^{zZz}'; sleep 10; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Array | |
| def range | |
| [ self.min, self.max ] | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Ruby 1.9 | |
| (0...8).map { (@__alphanums ||= [ ('a'..'z'), ('A'..'Z'), ('0'..'9') ].map { |r| r.to_a }.flatten).sample }.join |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module RandWaltzmann # Named after my first CS prof | |
| extend self | |
| def string(length=8) | |
| (0...length).map { (@__alphanums ||= [ ('a'..'z'), ('A'..'Z'), ('0'..'9') ].map { |r| r.to_a }.flatten)[rand(@__alphanums.size)] }.join | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Inspired by/stolen from: http://refactormycode.com/codes/1065-retry | |
| require 'logger' | |
| module Kernel | |
| def logger | |
| @logger = Logger.new(STDOUT) | |
| end | |
| end |
OlderNewer