Skip to content

Instantly share code, notes, and snippets.

View rubyandcoffee's full-sized avatar
🐒

Alexandra Wolfe rubyandcoffee

🐒
  • Cheshire, United Kingdom
View GitHub Profile
@rubyandcoffee
rubyandcoffee / contact_spec.rb
Created August 24, 2016 13:49
Spec for contacts
require 'spec_helper'
describe Contact do
it "has a valid factory" do
expect(build(:contact)).to be_valid
end
it { should validate_presence_of :first_name }
it { should validate_presence_of :last_name }
it { should validate_presence_of :email }
@rubyandcoffee
rubyandcoffee / contacts.rb
Created August 24, 2016 13:50
Factory for contact with Faker
require 'faker'
FactoryGirl.define do
factory :contact do |f|
f.first_name { Faker::Name.first_name }
f.last_name { Faker::Name.last_name }
f.email { Faker::Internet.email }
end
end
@rubyandcoffee
rubyandcoffee / gist:bf929fb1744c5163dcd603a25637b687
Created April 2, 2017 16:53
Open Files with subl command in terminal
Assume:
1. You have already installed Homebrew.
2. /usr/local/bin is your $PATH.
3. You are on Yosemite or El Capitain.
Solution: At first, run the following script on Terminal app to create specific symlink.
$ ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
Then,
@rubyandcoffee
rubyandcoffee / kill rails server process
Last active October 28, 2017 19:17
Killing a rails server process that's currently running.
1. lsof -wni tcp:3000
2. kill -9 PID
@rubyandcoffee
rubyandcoffee / terminal
Created February 3, 2018 13:00
Start/Stop Postgres
brew services start postgresql
brew services stop postgresql
@rubyandcoffee
rubyandcoffee / terminal
Last active February 3, 2018 13:47
Postgres Commands
# connect to postgres
psql postgres
# list databases
\list
# connect to database
\connect database_name
# show tables
https://rubystyle.guide/
# color schemes
To use the below, open iTerm then hit cmd+i, go to colours panel and import the colour scheme file.
lovelace: https://raw.githubusercontent.com/mbadolato/iTerm2-Color-Schemes/master/schemes/lovelace.itermcolors
# ~/bash_profile
export PS1="👾 > "
eval "$(rbenv init -)"
# status bar enabled with current directory and git state.
Atom UI theme: Mermaid Dark
Atom Syntax theme: Mermaid Dark
@rubyandcoffee
rubyandcoffee / PostgreSQL issues
Created February 18, 2020 21:19
Various issues with PostgreSQL
Run `postgres -D /usr/local/var/postgres` to diagnose issue
If it returns error:
```
FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 9.2, which is not compatible with this version 9.0.4.
```
Then run `brew postgresql-upgrade-database`