- Dynamic Dispatch
- Dynamic Method
- Ghost Methods
- Dynamic Proxies
- Blank Slate
- Kernel Method
- Flattening the Scope (aka Nested Lexical Scopes)
- Context Probe
- Class Eval (not really a 'spell' more just a demonstration of its usage)
- Class Macros
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
| # | |
| # With reference to | |
| # Just a run-down of TracePoint | |
| # | |
| # https://medium.com/@baweaver/exploring-tracepoint-in-ruby-part-one-example-code-2cf9b1a1b956 | |
| # Rotoscope tracks method invocations but not arguments | |
| # | |
| # https://github.com/Shopify/rotoscope | |
| # | |
| # Rack::MethodTrace - allows us to see which methods are called more than once and which are memoized |
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 Haml::Filters::CodeConcern | |
| extend ActiveSupport::Concern | |
| def render(text) | |
| <<~CODE | |
| <div class="sa-code-snippet-wrapper"> | |
| <div class="sa-code-snippet"> | |
| <div class="code-title">HAML Snippet</div> | |
| <button class="copy-code-button">Copy</button> | |
| <pre class="chroma"><code>#{Haml::Helpers.preserve text}</code></pre> | |
| </div> |
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
| # I want to take this array and return consecutive groups of numbers that are above or equal to 10. | |
| [7.5, 10, 10, 10, 9, 10, 11] | |
| # Enter, slice_when | |
| [7.5, 10, 10, 10, 9, 10, 11].slice_when { |i, j| i >= 10 && j < 10 || j >= 10 && i < 10 }.select { i >= 10 } | |
| # I don't want to repeat myself all the time, so boring | |
| # |
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
| days: 182 | |
| users: 122 |
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/local/bin/python3 | |
| from __future__ import print_function | |
| from ortools.linear_solver import pywraplp | |
| t = 'WhatIsX' | |
| s = pywraplp.Solver(t, pywraplp.Solver.GLOP_LINEAR_PROGRAMMING) | |
| x = s.NumVar(0, 1000, 'x') | |
| s.Add(x + 2*x + 3*x + 4*x == 10) # it's almost algebraic syntax |
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
| # based on the original Gist from mildmojo | |
| # https://gist.github.com/mildmojo/3724189 | |
| # | |
| module ActiveRecord | |
| module LeftJoinExtension | |
| extend ActiveSupport::Concern | |
| module ClassMethods | |
| # Simple left join taking advantage of existing Rails & Arel code | |
| def left_joins(*args) |
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
| conn = Faraday.new(url: 'http://www.bunyons.com') | |
| conn.post do |req| | |
| req.url '/dave/onion' | |
| req.headers['Referer'] = 'http://www.something.com' | |
| req.headers['User-Agent'] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36" | |
| req.headers['X-Forwarded-For'] = '86.185.170.5' | |
| req.headers['X-Requested-With'] = 'XMLHttpRequest' | |
| req.body = { plasticpantsid: 2403, arbitudeabuthnot: 'faff' } | |
| 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
| // This code is MIT licensed: http://creativecommons.org/licenses/MIT/ | |
| // Zenbe Inc (2009). | |
| // Ensure our Zenbe namespaces exist. | |
| window.zen = window.zen || {}; | |
| window.zen.util = window.zen.util || {}; | |
| /** | |
| * The DropManager class provides a pleasant API for observing HTML5 drag-n-drop | |
| * events, cleaning up the data that they return, and triggering the appropriate |
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
| >> t = TMail::Mail.new | |
| => #<TMail::Mail port=#<TMail::StringPort:id=0x3ff92369be30> bodyport=nil> | |
| >> t.to = "RobL <someaddress@robl.me>" | |
| => "RobL <someaddress@robl.me>" | |
| >> t.to | |
| => ["someaddress@robl.me"] | |
| -- | |
| >> t.to_addrs |
NewerOlder