Inspired by Literate CoffeeScript.
$ cat hello.litrb
Here's a simple program
puts "Hello, world"
$ ruby litrb.rb < hello.litrb
Hello, world
| button { | |
| position:relative; | |
| display:block; | |
| margin:50px; | |
| padding:0; | |
| width:250px; | |
| height:50px; | |
| border:none; | |
| border-radius:50px; |
| addLoadEvent = function (func) { | |
| if (typeof jQuery != "undefined") jQuery(document).ready(func); | |
| else if (typeof wpOnload != 'function') { | |
| wpOnload = func; | |
| } else { | |
| var oldonload = wpOnload; | |
| wpOnload = function () { | |
| oldonload(); | |
| func(); | |
| } |
| .postdetail article q,.postdetail article blockquote { | |
| position:relative; | |
| color:#666; | |
| display:block; | |
| font-family:"Adobe Garamond","Garamond",times,"times new roman",serif; | |
| font-style:italic; | |
| font-size:36px; | |
| line-height:42px; | |
| margin:15px 0; | |
| } |
| # gem install macaddr | into Gemfile if you want | |
| ==begin | |
| require 'macaddr' | |
| ==end | |
| require 'socket' | |
| gateway = `ip route show`.match(/default.*/)[0].match(/\d\d?\d?\.\d\d?\d?\.\d\d$ | |
| def local_ip | |
| orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily | |
| UDPSocket.open do |s| |
Inspired by Literate CoffeeScript.
$ cat hello.litrb
Here's a simple program
puts "Hello, world"
$ ruby litrb.rb < hello.litrb
Hello, world
| # .railsrc for Rails 3, encoding: utf-8 | |
| # see http://rbjl.net/49-railsrc-rails-console-snippets | |
| if !Rails.application then warn "Rails isn't loaded, yet... skipping .railsrc" else | |
| # # # | |
| def ripl?; defined?(Ripl) && Ripl.instance_variable_get(:@shell); end | |
| # # # | |
| # loggers |
Inspired by Literate CoffeeScript.
$ cat hello.litrb
Here's a simple program
puts "Hello, world"
$ ruby litrb.rb < hello.litrb
Hello, world
| -module(head_srv). | |
| -compile(export_all). | |
| %-export([start/1, benchmark/1, console_start/0, loop/1]). | |
| -include("jsonerl/jsonerl.hrl"). | |
| -record(command, {action, error, login, desc}). | |
| -record(logic_state, {ies = none}). | |
| -define(INTERNAL_TIMEOUT, 10000). | |
| -define(LISTEN_PORT, 6070). |
| hash_old = {"a"=>100, "b"=>""} | |
| Hash["a", "", "", ""].reject { |k,v| v.blank? if hash_old[k].blank? } | |
| # => {"a"=>""} |
| class Game | |
| attr_reader :name, :tags | |
| def initialize(name) | |
| @name = name | |
| @tags = [] | |
| end | |
| def year(value) | |
| @year = value |