It's common in Ruby to see some code setup a Struct like this:
class Specialized < Struct.new(:whatever)
# ... define custom methods here...
end| # LVDB - LLOOGG Memory DB | |
| # Copyriht (C) 2009 Salvatore Sanfilippo <[email protected]> | |
| # All Rights Reserved | |
| # TODO | |
| # - cron with cleanup of timedout clients, automatic dump | |
| # - the dump should use array startsearch to write it line by line | |
| # and may just use gets to read element by element and load the whole state. | |
| # - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands. | |
| # - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump! |
| /* bling.js */ | |
| window.$ = document.querySelector.bind(document); | |
| window.$$ = document.querySelectorAll.bind(document); | |
| Node.prototype.on = window.on = function(name, fn) { this.addEventListener(name, fn); }; | |
| NodeList.prototype.__proto__ = Array.prototype; | |
| NodeList.prototype.on = function(name, fn) { this.forEach((elem) => elem.on(name, fn)); }; |
| # How to update values on immutable objects? | |
| class Foo | |
| def initialize(attrs) | |
| @x = attrs.fetch(:x) | |
| @y = attrs.fetch(:y) | |
| freeze | |
| end | |
| end |
| * rom (ruby-object-mapper) | |
| * rohm | |
| * rome (easier to pronounce) | |
| * resistance | |
| * bloom | |
| * allure | |
| * agrabla (esperanto) agreeable, enjoyable, lovely, nice, pleasant | |
| * vigor (power, energy) | |
| * moxie (courage) | |
| * "mowr" (pronounced "mower", meaning nothing i can think of, except: "mapping objects with ruby") |
| ### | |
| # Scheme code is translated to YARV byte code, then evaluated in the | |
| # Ruby Virtual Machine | |
| require 'rbconfig' | |
| require 'dl' | |
| require 'fiddle' | |
| require 'strscan' | |
| class RubyVM |
| $stack, $draws = [], {} | |
| def method_missing *args | |
| return if args[0][/^to_/] | |
| $stack << args.map { |a| a or $stack.pop } | |
| $draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :< | |
| end | |
| class Array | |
| def +@ |
| DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
| Version 2, December 2004 | |
| Copyright (C) 2011 Mathieu 'p01' Henri - http://www.p01.org/releases/ | |
| Everyone is permitted to copy and distribute verbatim or modified | |
| copies of this license document, and changing it is allowed as long | |
| as the name is changed. | |
| DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |