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 CanHazRoutes | |
| include ActionController::UrlWriter | |
| host = case ENV['RAILS_ENV'] | |
| when "production" | |
| "prod.com" | |
| when "staging" | |
| "stage.com" | |
| when "development" | |
| "app.local" |
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
| trials = [] | |
| 10000.times{ trials << rand(6) } | |
| trials.uniq.map do |u| | |
| trials.select { |t| t.equal? u }.size | |
| end.collect do |c| | |
| c.to_f / trials.size | |
| 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
| #!/bin/sh | |
| REPO=$1 | |
| git clone $REPO | |
| cd `basename $REPO .git` | |
| for BRANCH in `git branch -r`; do | |
| git co --track \ | |
| -b remote/$BRANCH \ | |
| $BRANCH | |
| 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
| #!/usr/bin/env ruby | |
| puts "looking for the gems to upgrade..." | |
| gem_info = Struct.new(:name, :version) | |
| to_reinstall = [] | |
| Dir.glob('/Library/Ruby/Gems/**/*.bundle').map do |path| | |
| path =~ /.*1.8\/gems\/(.*)-(.*?)\/.*/ | |
| name, version = $1, $2 | |
| bundle_info = `file path` | |
| to_reinstall << gem_info.new(name, version) unless bundle_info =~ /bundle x86_64/ | |
| 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
| irb(main):054:0> class Cat | |
| irb(main):055:1> def eigen | |
| irb(main):056:2> class << self | |
| irb(main):057:3> self | |
| irb(main):058:3> end | |
| irb(main):059:2> end | |
| irb(main):060:1> end | |
| => nil | |
| irb(main):061:0> c1 = Cat.new | |
| => #<Cat:0x1017562d0> |
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
| [user@host ~]$ cat /proc/7128/cmdline | |
| /usr/java/java/bin/java-Djava.awt.headless=true-Xms128M-Xmx256M-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager-Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties-Djava.endorsed.dirs=/usr/local/tomcat/common/endorsed-classpath:/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/commons-logging-api.jar-Dcatalina.base=/usr/local/tomcat-Dcatalina.home=/usr/local/tomcat-Djava.io.tmpdir=/usr/local/tomcat/temporg.apache.catalina.startup.Bootstrapstart |
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
| # collect information about a running process | |
| # ruby debug.rb <pid> | |
| begin | |
| raise ArgumentError unless pid = ARGV[0] | |
| pid = pid.to_i | |
| Process.kill(0,pid) | |
| rescue TypeError, ArgumentError | |
| raise 'pid required' | |
| rescue Errno::ESRCH |
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 Inline | |
| include Haml::Filters::Base | |
| def self.[](key) | |
| @@data[key.to_s] rescue nil | |
| end | |
| def render(str) | |
| @@data = Hash[*str.split(/^\s*@@\s*(\w+)\s*\n/m)[1..-1]] | |
| return nil |
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
| # include this in application controller | |
| module Authentication | |
| protected | |
| # Inclusion hook to make #current_user and #signed_in? | |
| # available as ActionView helper methods. | |
| def self.included(base) | |
| base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method | |
| end | |
| # Returns true or false if the user is signed in. |
OlderNewer