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
| data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script> |
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
| require "test" | |
| CONSTANT = 777 | |
| # Sample comment | |
| class Module::Class | |
| include Testcase | |
| render :action => 'foo' | |
| def foo(parameter) |
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
| require 'ap' | |
| require 'ripper' | |
| CLASS_TEXT = "class A; end; class B; end" | |
| CLASS_SEXP = Ripper.sexp(CLASS_TEXT) | |
| BIG_TEXT = "class A; def a; @a = b; end; def b; @d = a; @e = a; end; end; module B; def b; end; end" | |
| BIG_SEXP = Ripper.sexp(BIG_TEXT) |
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 PhoneQuery | |
| def initialize(input) | |
| @input = input | |
| end | |
| def to_sql | |
| query = Phone.where('(1 = 0)').to_sql | |
| return query if @input.blank? |
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
| Boot into single user mode (press Command-S at power on) | |
| Type fsck -fy | |
| Type mount -uw / | |
| Type launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist | |
| Type dscl . -passwd /Users/username password, replacing username with the targeted user and password with the desired password. | |
| Reboot |
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 QueryingWithBlock | |
| def first_with(&block) | |
| find_each do |record| | |
| return record if block.call(record) | |
| end | |
| end | |
| end | |
| # ActiveRecord::Relation includes QueryingWithBlock | |
| ActiveRecord::Relation.class_eval do |
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
| test_string = 'Informação' | |
| Encoding.aliases.values.uniq.each do |encoding| | |
| begin | |
| puts "In #{encoding}: #{test_string.clone.force_encoding(encoding)}" | |
| rescue | |
| puts "Barfed for #{encoding}" | |
| 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
| # wicked pdf | |
| module WickedPdfHelper | |
| def render(options = nil, *args, &block) | |
| if options.is_a?(Hash) && options.has_key?(:pdf) | |
| puts 'do pdf stuff' | |
| end | |
| super | |
| 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
| 1.upto(100).each do |number| | |
| if number % 3 != 0 && number % 5 != 0 | |
| puts "#{number}: #{number}" | |
| else | |
| puts "#{number}: #{number % 3 == 0 ? 'Fizz' : '' }#{number % 5 == 0 ? 'Buzz' : ''}" | |
| 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
| class MysqlQuery | |
| def initialize | |
| @query = "" | |
| end | |
| end |