Skip to content

Instantly share code, notes, and snippets.

View nmenag's full-sized avatar

Nicolas Mena nmenag

View GitHub Profile
@nmenag
nmenag / docker-compose.yml
Created July 15, 2022 00:57 — forked from rmoff/docker-compose.yml
Docker-Compose for Kafka and Zookeeper with internal and external listeners
---
version: '2'
services:
zookeeper:
image: confluentinc/cp-zookeeper:latest
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
kafka:
class RenameReadColumToState < ActiveRecord::Migration
def change
add_column :messages, :state, :integer, default: 0
execute "UPDATE messages SET state = CAST(read AS INTEGER);"
remove_column :messages, :read
end
end
@nmenag
nmenag / gist:f5c268d833e7aeeacf3f6cb8b1a8f7d9
Created November 12, 2017 16:17 — forked from metaskills/gist:2836849
Basic Save & Open Page For Poltergeist
def save_and_open_page
dir = "#{Rails.root}/tmp/cache/capybara"
file = "#{dir}/#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}.png"
FileUtils.mkdir_p dir
page.driver.render file
wait_until { File.exists?(file) }
system "open #{file}"
end

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

@nmenag
nmenag / gist:ab9cd4f49ddcd54bd3cc
Last active January 30, 2016 19:54 — forked from lttlrck/gist:9628955
Rename branch remote in Git
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote