Database Cleaner:
group :test do ...
gem "database_cleaner"
...
endSupport
| require 'rails_helper' | |
| # class Cat < ApplicationRecord | |
| # has_many :cat_toy | |
| # has_many :toys, through: :cat_toy, dependent: :destroy | |
| # end | |
| # | |
| # class Toy < ApplicationRecord | |
| # end | |
| # |
Database Cleaner:
group :test do ...
gem "database_cleaner"
...
endSupport
| # Originally posted here: https://glot.io/snippets/es9vhlp4hs | |
| # ©2017 Bob. No rights reserved. | |
| def some_func(x) | |
| x + " sucks" | |
| end | |
| a = ["primus", "bob", "black hole"] | |
| puts "\nthe most sane way" |
| package main | |
| import ( | |
| "fmt" | |
| "sync" | |
| "time" | |
| ) | |
| func waitForSignal() { | |
| var m sync.Mutex |
| const color = (() => { | |
| const RESET = '\x1b[0m' | |
| const BRIGHT = '\x1b[1m' | |
| const DIM = '\x1b[2m' | |
| const RED = '\x1b[31m' | |
| const GREEN = '\x1b[32m' | |
| const YELLOW = '\x1b[33m' | |
| const BLUE = '\x1b[34m' | |
| const MAGENTA = '\x1b[35m' | |
| const CYAN = '\x1b[36m' |
There are 3 tools/tricks which are pretty essential to writing Go code on a team or open source project which I highly recommend:
Set up your editor to automatically run the code through goimports once you hit save.
It's extremely fast. It formats your code using the standard gofmt tool. It automatically adds/removes/organizes your import lines. Note that Go uses tabs, so I recommend setting your editor's tab-width to 2 or 4, whichever you're used to. Anything but 8. Editor support:
no notes
| Africa/Abidjan | |
| Africa/Accra | |
| Africa/Addis_Ababa | |
| Africa/Algiers | |
| Africa/Asmara | |
| Africa/Bamako | |
| Africa/Bangui | |
| Africa/Banjul | |
| Africa/Bissau | |
| Africa/Blantyre |
| Array.prototype.paraMap = function(...fns) { | |
| return fns.map(fn => this.map(fn)) | |
| } | |
| Array.prototype.paraReduce = function(...fns) { | |
| let reduceArgs | |
| let init = fns[fns.length - 1] | |
| if (typeof init !== 'function') { | |
| reduceArgs = fns.slice(0, -1).map(fn => [fn, init]) | |
| } else { |
I hereby claim:
To claim this, I am signing this object: