Skip to content

Instantly share code, notes, and snippets.

View dankmitchell's full-sized avatar
🎯
Focusing

Dan Mitchell dankmitchell

🎯
Focusing
View GitHub Profile
@dansteele
dansteele / create_review_app_subdomain.rake
Last active September 24, 2024 06:44
Use a sub-subdomain on Heroku review apps with DNSimple. Run this task from your app.json in your postdeploy script.
namespace :staging do
desc 'create subdomain DNS record for Heroku review app'
task :publish_dns do
require 'dnsimple'
require 'platform-api'
STAGING_DOMAIN = 'mystagingdomain.com'.freeze
DNSIMPLE_ACCOUNT_ID = .freeze
heroku_app_name = ENV['HEROKU_APP_NAME']
subdomain = heroku_app_name.match(/.*(pr-\d+)/).captures.first
@giannisp
giannisp / gist:ebaca117ac9e44231421f04e7796d5ca
Last active July 14, 2024 18:27
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install [email protected]
brew unlink [email protected]
brew link postgresql
@quis
quis / routes.js
Last active August 1, 2018 14:41
How to integrate the prototype kit with GOV.UK Notify
// Add this code to the top of routes.js
// process.env.NOTIFYAPIKEY is a special kind of variable that Node
// pulls from the environment your prototype is running in
//
// To set it locally, run this command in your Terminal, in the root
// folder of your prototype:
// echo NOTIFYAPIKEY=xxxxxxx >> .env
// (where xxxxxxx is a key you’ve created in Notify)
//
// To set it on Heroku, go to the settings page on your app, click
@saad749
saad749 / AlertViewModel.cs
Created August 22, 2016 12:43
Easy Generic way to Display Alerts in ASP.Net Core
public class AlertViewModel
{
public string AlertType { get; set; }
public string AlertTitle { get; set; }
public string AlertMessage { get; set; }
public AlertViewModel(string type, string title, string message)
{
AlertType = type;
AlertTitle = title;

ES6 cheat sheet, with very tasty examples

Declarations

let - prevents javascript hoisting to top of document, variables are scoped to function (no more undefined error when trying to call a var outside a functions scope, you get a ReferenceError which is more predictable/expected).

const - provides constants, cannot be redefined, raises syntax error

Function Arguments

@camillebaldock
camillebaldock / oyster.rb
Last active February 4, 2017 13:43
Oyster journey history scraping script
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require 'capybara/poltergeist'
require 'awesome_print'
Capybara.run_server = false
Capybara.current_driver = :poltergeist
class Oyster