Skip to content

Instantly share code, notes, and snippets.

upstream puma {
server unix:///home/user/apps/meudominio/shared/tmp/sockets/certamei-puma.sock;
}
server {
listen 80;
server_name meudominio.com.br www.meudominio.com.br;
root /var/www/meudominio.com.br/html/;
access_log /var/log/nginx/access.log;
Event delegation
$(document).on('turbolinks:load',function() {
employees_table_list();
}).on('ajax:success', '#employee-form', function(){
employees_table_list();
});
@starwels
starwels / main.rb
Last active December 17, 2019 18:23
require 'open-uri'
require 'net/http'
URL = 'bucket_url'
DIGITS_AND_LETTERS = (0..9).to_a.concat(('a'..'z').to_a)
count = 0
DIGITS_AND_LETTERS.repeated_permutation(32) do |num|
begin
class BarController < ApplicationController
before_action :find_bar
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
def show
end
private
10.times do |num|
Post.create(title: "Ruby is Awesome #{num}", body: 'Indeed it is') do |post|
5.times { Comment.create(body: "Comment #{num}", post: post) }
end
end
<div>
posts: <%= @posts.count %> <br>
<% @posts.each do |post| %>
<%= post.title %>
<hr>
<%= post.body %>
<% if post.created_at < post.updated_at %>
(edited)
<% else %>
(first version)
class PostsController < ApplicationController
def index
@posts = Post.all.order(id: :asc)
end
end
class Post < ApplicationRecord
has_many :comments
end
class Comment < ApplicationRecord
belongs_to :post
end
<div>
posts: <%= @posts.size %> <br>
<% @posts.each do |post| %>
<%= post['title'] %>
<hr>
<%= post['body'] %>
<%= post['status'] %>
<hr>
comments: <%= post['comments'].size %> <br>
<% post['comments'].each do |comment| %>
class PostPresenter
def index
posts = Post.includes(:comments).order(id: :asc).as_json(include: [:comments])
posts.map { |post| post['status'] = post['created_at'] < post['updated_at'] ? '(edited)' : '(first version)' }
end
end