Skip to content

Instantly share code, notes, and snippets.

@maxmilton
maxmilton / asynchronous-sentry-js-error-tracking.html
Last active April 27, 2020 15:43
How to load the Sentry JavaScript error tracking script 'raven.js' asynchronously and still capture errors before the script is loaded.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Asynchronous Sentry JavaScript Error Tracking</title>
<!-- putting your CSS near the top is always a good idea -->
<link rel="stylesheet" href="/app.css"></link>
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do
@jeffutter
jeffutter / cleandocker.sh
Created August 7, 2014 04:55
Clean Old Docker Containers/Images
#!/bin/bash
containers=$( (docker ps ; docker ps -a ) | tr -s ' ' | sort | uniq -u |grep -v '_data'|grep -v "CONTAINER" | awk '{print $1}' )
if [[ -n $containers ]]; then
docker rm $containers
fi
images=$(docker images |grep '<none>'| awk '{print $3}')
if [[ -n $images ]]; then
docker rmi $images
fi
package main
import (
"net/http"
"database/sql"
"fmt"
"log"
"os"
)
@SabretWoW
SabretWoW / rspec_model_testing_template.rb
Last active March 7, 2024 03:56
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@cainlevy
cainlevy / with_retries.rb
Created October 28, 2011 21:19
with_retries{} helper to easily catch and retry exceptions in Ruby
module Retriable
# This will catch any exception and retry twice (three tries total):
# with_retries { ... }
#
# This will catch any exception and retry four times (five tries total):
# with_retries(:limit => 5) { ... }
#
# This will catch a specific exception and retry once (two tries total):
# with_retries(Some::Error, :limit => 2) { ... }
#
@nruth
nruth / tests_spec.rb
Created July 30, 2010 20:48
how not to loop/nest rspec example groups (where you want to iterate diferent let/before variable values)
class Tests
SUBTESTS = %w(Abstract Decision Quantitative Verbal)
end
describe Tests do
describe "before assigning @ - " do
describe "this doesn't work because the loops are all at the same describe level (the befores override one another)" do
Tests::SUBTESTS.each do |test|
before(:each) do