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.

version: '2.0'
services:
couchpotato:
image: linuxserver/couchpotato
ports:
- 5050:5050
volumes:
- couchpotato:/config:rw
- movies:/movies:rw
- downloads:/downloads:rw
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/,
@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()
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
@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
var MyClass = function() {
this.myAttribute = 1;
return this;
};
MyClass.classMethod = function() {
};
MyClass.prototype.instancMethod = function() {
# RecursiveClosedStruct is similar to OpenStruct, except:
#
# * Immutable. Cannot be changed after instantiation.
# * Raises NoMethodError on undefined methods instead of returning nil.
# * Recursively coerces descendants into a RecursiveClosedStruct.
#
# NoMethodError example:
# struct = RecursiveClosedStruct.new(key1: "value")
# struct.key1 # => "value"
# struct.key2 # => NoMethodError
@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
anonymous
anonymous / gist:4333310
Created December 19, 2012 00:09
(function(root) { // Wrap our entire code in anyonmous function. Minimise your chance to leak scope into the global namespace. See last line.
'use strict'; // http://stackoverflow.com/questions/1335851/what-does-use-strict-do-in-javascript-and-what-is-the-reasoning-behind-it
var $ = root.$; // Convient access to the jQuery object. Chaining is expensive in JS.
root.Search = (function() { // Wrap the entire class in an anonymous function. This guarantees we will not leak scope. We assign the class to the root object. In this case, window.
function Search(el) { // Create a search object. This is also the constructor for the class.
this.el = el;// Assign an ivar
}