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 BlahPlugin | |
| VERSION = '1.0.0' | |
| class << self | |
| # add plugin to AR only if it hasn't been included before, | |
| # which may cause stack-level-too-deep errors if you're aliasing methods | |
| # | |
| def enable_activerecord | |
| return if ActiveRecord::Base.respond_to? :acts_as_blah | |
| ActiveRecord::Base.extend BlahPlugin::Macro |
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
| function parse_git_deleted { | |
| [[ $(git status | grep deleted:) != "" ]] && echo "-" | |
| } | |
| function parse_git_added { | |
| [[ $(git status | grep "Untracked files:") != "" ]] && echo '+' | |
| } | |
| function parse_git_modified { | |
| [[ $(git status | grep modified:) != "" ]] && echo "*" | |
| } | |
| function parse_git_dirty { |
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
| (1..1325).to_a.each do |num| | |
| link = "http://www.questionablecontent.net/comics/#{num}.png" | |
| `curl #{link} > ~/Pictures/QC/#{num}.png &2>1` | |
| puts "#{num} downloaded..." | |
| 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
| controller_name, action_name = page.split(" ") | |
| controller.controller_name.should == controller_name | |
| controller.action_name.should == action_name |
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
| set :application, "TODO" | |
| set :scm_username, "TODO" | |
| set :user, application # assumes you create 1 user per app | |
| set :domain, "#{application}.com" # this can be changed | |
| set :use_sudo, false # everything is owned by user | |
| role :app, domain # These options are fine for most cases | |
| role :web, domain |
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
| <VirtualHost *:80> | |
| ServerName sub.domain.com | |
| ProxyPass / http://192.168.1.253:8080/ | |
| ProxyPassReverse / http://192.168.1.253:8080/ | |
| # The endpoint has a mandatory password that I want to avoid requiring users to type | |
| # I.e. something like this would be nice (but does not work) | |
| # ProxyPass / http://username:[email protected]:8080/ |
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
| There are many like it. |
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
| >> (1..10).map(&:object_id) | |
| => [3, 5, 7, 9, 11, 13, 15, 17, 19, 21] | |
| >> (-10..-1).map(&:object_id) | |
| => [-19, -17, -15, -13, -11, -9, -7, -5, -3, -1] | |
| >> ObjectSpace._id2ref(-1) | |
| => -1 | |
| >> ObjectSpace._id2ref(-5) | |
| => -3 | |
| >> ObjectSpace._id2ref(-2) # if -2 = 0xfffffffe, then -1 == 0xffffffff | |
| RangeError: 0xfffffffe is not id value |
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 Abc | |
| def self.~@ | |
| puts "WTF" | |
| end | |
| end | |
| ~Abc # => "WTF" |
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 Point | |
| attr_reader :x, :y | |
| def initialize(x, y) | |
| @x, @y = x, y | |
| end | |
| def ~ point | |
| Math.sqrt((point.x - self.x) ** 2 + | |
| (point.y - self.y) ** 2) |