This file contains 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 BadIdea | |
def self.method_added(method_name) | |
return if @mid_define | |
@obj ||= Object.new | |
@old_methods ||= {} | |
@old_methods[method_name] ||= [] | |
@old_methods[method_name] << self.instance_method(method_name) |
This file contains 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
noah@Noahs-MBP activerecord % chruby system | |
noah@Noahs-MBP activerecord % gem env | |
RubyGems Environment: | |
- RUBYGEMS VERSION: 3.0.3.1 | |
- RUBY VERSION: 2.6.10 (2022-04-12 patchlevel 210) [universal.arm64e-darwin22] | |
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.6.0 | |
- USER INSTALLATION DIRECTORY: /Users/noah/.gem/ruby/2.6.0 | |
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby | |
- GIT EXECUTABLE: /usr/bin/git | |
- EXECUTABLE DIRECTORY: /usr/local/bin |
This file contains 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
# Change a sci-notation string to a float string without using the Numeric class in between. At all. | |
# Assume input string in "12345e7" format, | |
# return string in "123450000000.0" format | |
def exp2sf(exp_str) | |
mant, ex = exp_str.split("e") | |
zeroes = "" | |
next_place_zeroes = "0" |
This file contains 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
# r00lz/lib/r00lz.rb | |
module R00lz | |
def self.to_underscore(s) | |
s.gsub( | |
/([A-Z]+)([A-Z][a-z])/, | |
'\1_\2').gsub( | |
/([a-z\d])([A-Z])/, | |
'\1_\2').downcase | |
end | |
end |
This file contains 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
Make an Outline: | |
* Brainstorm | |
* Categorize (arrange into categories and subcategories) | |
* Outline | |
Introduction: | |
* Provide the Reader with Context | |
* State the main theme | |
* Explain the organization (what you'll get, how you'll get it) |
This file contains 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 LibraryError < RuntimeError; end | |
class AppError < RuntimeError; end | |
# Library code | |
def library_call | |
begin | |
1/0 | |
rescue | |
raise LibraryError.new("Something went wrong") | |
end |
This file contains 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 ParentClass | |
puts "Self when defining ParentClass: #{self.class} / #{self.inspect}" | |
def parent_method | |
puts "Self inside parent_method: #{self.class} / #{self.inspect}" | |
end | |
end | |
module MyModule | |
def self.module_obj_method | |
puts "Self inside module_obj_method: #{self.class} / #{self.inspect}" |
This file contains 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
<h1>D3 Shaded Globe</h1> | |
<!-- Add scripts for topoJson, jQuery --> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="http://d3js.org/topojson.v1.min.js"></script> | |
<script src="http://datamaps.github.io/scripts/datamaps.world.min.js"></script> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" ></script> | |
<div class="world-map" | |
style="position: relative; height: 500px"> |
This file contains 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
<!doctype html> | |
<script src="http://code.shutterstock.com/rickshaw/vendor/d3.v2.js"></script> | |
<script src="http://code.shutterstock.com/rickshaw/rickshaw.min.js"></script> | |
<div id="chart"></div> | |
<script> | |
// Return an xinterp function for a given graph | |
function xinterp_on_graph(graph) { |
This file contains 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
<!doctype html> | |
<script src="http://code.shutterstock.com/rickshaw/vendor/d3.v2.js"></script> | |
<script src="http://code.shutterstock.com/rickshaw/rickshaw.min.js"></script> | |
<div id="chart"></div> | |
<script> | |
var graph = new Rickshaw.Graph( { |