Skip to content

Instantly share code, notes, and snippets.

@mrispoli24
mrispoli24 / setting-up-heroku-and-cloudflare.md
Created October 15, 2018 18:41
Setting up Heroku and Cloudflare (the right way)

Setting up Heroku and Cloudflare (the right way)

The following outlines how to setup Heroku + Cloudflare with a full SSL certificate. What this means is that communication between the browser and the Cloudflare CDN is encrypted as well as communication between Cloudflare and Heroku’s origin server. Follow these steps exactly and the setup is a breeze.

Step 1: Set up domain names in Heroku

First you want to add the root domain and the www domain to heroku. You do this by clicking into your production application, then going to settings and then scrolling down to Domains and certificates.

Here you will add <your_domain>.com and www.<your_domain>.com. This will give you two CNAME records. They will look something like <your_domain>.com.herokudns.com and www.<your_domain>.com.herokudns.com.

Step 2: Add CNAME records to Cloudfare.

@coreyhaines
coreyhaines / .rspec
Last active April 11, 2024 00:19
Active Record Spec Helper - Loading just active record
--colour
-I app
@jonleighton
jonleighton / gist:7122210
Created October 23, 2013 16:48
Report Rails deprecation warnings to Honeybadger (useful in production if there might be lines of code not covered by your tests - the horror!). Place this in your config/environments/production.rb
ActiveSupport::Notifications.subscribe('deprecation.rails') do |name, start, finish, id, payload|
Honeybadger.notify(
error_class: "DEPRECATION WARNING",
error_message: payload[:message],
backtrace: payload[:callstack]
)
end
module DelayedJob
module Matchers
def enqueue_delayed_job(handler)
DelayedJobMatcher.new handler
end
class DelayedJobMatcher
def initialize(handler)
@handler = handler
@attributes = {}
@progrium
progrium / consul.py
Last active September 16, 2020 14:29
Consul health check integration with DataDog
import requests
from checks import AgentCheck
class ConsulCheck(AgentCheck):
def should_check(self):
r = requests.get(self.init_config["consul_url"] + "/v1/agent/self")
if r.status_code != 200:
return False
agent = r.json()
@caged
caged / graphite.md
Created March 3, 2012 20:25
Installing Graphite on OS X Lion

This is a general overview (from memory) of the steps I used to install graphite (http://graphite.wikidot.com) on OS X Lion. I think the steps are in order but YMMV. Please fork and fix if you find an error.

Install Python 2.7.2

brew install python

Check your env

$ python --version
version: '2.0'
services:
couchpotato:
image: linuxserver/couchpotato
ports:
- 5050:5050
volumes:
- couchpotato:/config:rw
- movies:/movies:rw
- downloads:/downloads:rw
@mislav
mislav / fat-logfiles.sh
Last active December 22, 2018 19:56
Find "*.log" files in your home dir, sort them by fattest-first, and calculate the size of them all together.
find ~ -name '*.log' -print0 | xargs -0 -L1 stat -f'%z %N' | sort -rn | tee fat-logfiles.txt | head
awk '{ total += $1 } END { printf "total: %5.2f MiB\n", total/1024/1024 }' < fat-logfiles.txt
require "rspec"
require "json"
require "dry-types"
require "dry-validation"
module Types
include Dry::Types.module
RegionCode = Types::Strict::String.constrained(
format: /\A(au|nz|uk|ie)\z/,
config.jobs = ActiveSupport::OrderedOptions.new
# Controls whether or not workers report heartbeats
config.jobs.heartbeat_enabled = true
# How often workers should send heartbeats
config.jobs.heartbeat_interval_seconds = 60
# How long a worker can go without sending a heartbeat before they're considered dead
config.jobs.heartbeat_timeout_seconds = 3 * 60
# How often to check for dead workers
config.jobs.dead_worker_polling_interval_seconds = 60