Database Cleaner:
group :test do ...
gem "database_cleaner"
...
end
Support
fn subscriber() -> impl tracing::subscriber::Subscriber { | |
use tracing_subscriber::{fmt::format::FmtSpan, prelude::*}; | |
tracing_subscriber::registry() | |
.with(tracing_subscriber::EnvFilter::from_default_env()) | |
.with( | |
tracing_subscriber::fmt::layer() | |
.compact() | |
.with_target(false) | |
.without_time() | |
.with_span_events(FmtSpan::CLOSE), |
package main | |
import ( | |
"fmt" | |
"io" | |
"time" | |
"github.com/opentracing/opentracing-go" | |
otlog "github.com/opentracing/opentracing-go/log" | |
"github.com/rs/zerolog/log" |
require 'base64' | |
require 'openssl' | |
require 'securerandom' | |
require 'uri' | |
BASE_URL = ENV['OAUTH2_BASE_URL'] | |
REDIRECT_URI = ENV['REDIRECT_URI'] | |
CLIENT_ID = ENV['OAUTH2_CLIENT_ID'] | |
code_verifier = Base64.urlsafe_encode64(SecureRandom.bytes(128), padding: false) |
#!/usr/bin/env ruby | |
require 'logger' | |
require 'semantic_logger' | |
class KubeFmt < SemanticLogger::Formatters::Json | |
# redefine the defaults for log_host and log_application to be false | |
def initialize( | |
time_format: :iso_8601, log_host: false, log_application: false, | |
time_key: :timestamp |
request = require('superagent') | |
request.get('http://httpbin.org/status/200') | |
.then(req => console.log(`got status: ${req.status}`)) | |
.catch(err => console.error(err)) | |
// got status: 200 | |
request.get('http://httpbin.org/status/500') | |
.then(req => console.log(`got status: ${req.status}`)) |
class CreateCats < ActiveRecord::Migration[5.0] | |
def change | |
create_table :cats do |t| | |
t.string :name | |
t.timestamps | |
end | |
end | |
end |
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"
...
end
Support
# 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 |