Erlang/OTP 18 RC-1
Elixir 1.1.0-dev
-
new
-
put
- 100 elements
MapSet: 10000000 0.16 µs/op
# We do this at compile-time as we don't have Mix available in releases. | |
@version Mix.Project.config().version | |
def start(_type, _args) do | |
#... | |
with {:ok, _} = result <- Supervisor.start_link(children, options) do | |
MyApp.Fluxter.write("start", version: @version) | |
result | |
end |
Erlang/OTP 18 RC-1
Elixir 1.1.0-dev
new
put
MapSet: 10000000 0.16 µs/op
require 'sinatra' | |
set server: :thin | |
get '/' do | |
erb :welcome | |
end | |
get '/stream', provides: 'text/event-stream' do | |
stream do |out| | |
loop do |
//= require jquery | |
//= require jquery_ujs | |
$(function() { | |
var source = new EventSource('/stream'); | |
source.addEventListener('counter', function(e) { | |
$('body').after(e.data + '<br />'); | |
}); | |
}); |
<%= simple_form_for(@product) do |f| %> | |
<%= f.input :title %> <!-- string --> | |
<%= f.input :description %> <!-- text --> | |
<%= yield(f) if block_given? %> | |
<%= f.button :submit %> | |
<% end %> |
class Article < ActiveRecord::Base # Product class is similar | |
belongs_to :user | |
has_many :media, as: :ownable | |
with_options through: :media, source: :representable do |assn| | |
assn.has_many :videos, source_type: 'Video' | |
assn.has_many :images, source_type: 'Image' | |
end | |
end |
<%= form_for @post do |f| %> | |
<%= f.text_field :title, value: 'It will never change', readonly: true %> | |
<%= f.text_field :description, value: 'You will not see it in params', disabled: true %> | |
<%= f.button :submit %> | |
<% end %> | |
<!-- params[:post] => { "title"=>"It will never change" } --> |
% rails g model Hotel | |
% rails g model Hotel::Translation # or hotel/translation |
module VirtualAttributes | |
extend ActiveSupport::Concern | |
class VirtualAttribute | |
attr_reader :name, :type | |
def initilaize(name, type = :string) | |
@name = name | |
@type = type | |
end |
module VirtualAttributes | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def attr_virtual(*attrs) | |
options = attrs.extract_options! | |
attrs.each do |attr| | |
class_eval do | |
send("attr_accessor", attr) |