Skip to content

Instantly share code, notes, and snippets.

View almokhtarbr's full-sized avatar
👋

almokhtar almokhtarbr

👋
  • 08:17 (UTC -04:00)
View GitHub Profile
Opening/Creating CSV File
First up, require the CSV library in your file. You don't need to install any gem for it, it comes bundled with your installation of ruby.
require "csv"
Then, to create a new CSV file you're going to;
csv = CSV.open("people.csv", "a+")
This will "open" a CSV file called "people.csv" in read-write mode where new writes will be added to the back of the file (append). If the file doesn't exist yet, it'll create it. Here's an overview of the different modes;
Modes Description
ActiveJob.perform_now
ActiveJob.perform_now
-scheme:chrome-extension
class Person < ActiveRecord::Base
attr_accessor :skip_some_callbacks
before_validation :do_something, unless: :skip_some_callbacks
after_validation :do_something_else, unless: :skip_some_callbacks
end
person = Person.new(person_params)
person.skip_some_callbacks = true
person.save
gem 'pg'
require 'pg'
def with_db
db = PG.connect(
dbname: 'dbname',
user: 'user',
password: 'password'
)
begin
yield db
register via the static website
add url to /etc/hosts
go to link with 3000
ex
http://conway-and-hicks-co.inc.services:3000
git branch -r --sort=-committerdate --format='%(HEAD)%(color:yellow)%(refname:short)|%(color:bold green)%(committerdate:relative)|%(color:blue)%(subject)|%(color:magenta)%(authorname)%(color:reset)' --color=always | column -ts'|'
@almokhtarbr
almokhtarbr / rack
Last active September 24, 2021 12:42
export RACK_TIMEOUT_SERVICE_TIMEOUT=?
Apartment::TenantNotFound: One of the following schema(s) is invalid: "sdf-sdh" "demo-1", "shared_extensions"
/Users/almokhtar/Desktop/vroom/app/models/tenant.rb:41:in `switch_to'
/Users/almokhtar/Desktop/vroom/app/models/tenant.rb:77:in `block in with_each'
/Users/almokhtar/Desktop/vroom/app/models/tenant.rb:76:in `with_each'
/Users/almokhtar/Desktop/vroom/lib/tasks/quote.rake:6:in `block (2 levels) in <main>'
Apartment::Tenant.create('sdf-sdh')