Skip to content

Instantly share code, notes, and snippets.

@scottserok
scottserok / schema_initializer.rb
Created April 14, 2021 07:47
A module that combines dry-initializer and dry-schema
require 'bundler/inline'
require 'json'
gemfile do
source 'https://rubygems.org'
gem 'dry-initializer'
gem 'dry-schema'
end
@scottserok
scottserok / sendgrid-events.json
Created December 4, 2020 04:45
Sendgrid webhook event examples copied from https://sendgrid.com/docs/for-developers/tracking-events/event/ on 2020-12-04
[
{
"email": "example@test.com",
"timestamp": 1513299569,
"smtp-id": "<14c5d75ce93.dfd.64b469@ismtpd-555>",
"event": "processed",
"category": "cat facts",
"sg_event_id": "sg_event_id",
"sg_message_id": "sg_message_id"
},
@scottserok
scottserok / revoke.rb
Last active November 11, 2020 01:06
Revoke a Salesforce OAuth token
#!/usr/bin/env ruby
# We revoke the OAuth token by sending an HTTP POST to salesforce.com/services/oauth2/revoke
# Usage
# ruby revoke.rb myOauthtoken
#
# https://help.salesforce.com/articleView?id=remoteaccess_revoke_token.htm&type=0
#
# POST /revoke HTTP/1.1
# Host: https://test.salesforce.com/services/oauth2/revoke
@scottserok
scottserok / Procfile
Created April 20, 2020 03:14
Webpack for Jekyll
jekyll: bundle exec jekyll s
webpack: webpack -w
@scottserok
scottserok / head.html
Created April 20, 2020 03:13
Webpack for Jekyll
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="{{ "/assets/styles.css" | relative_url }}">
{% asset bundle %}
</head>
@scottserok
scottserok / package.json
Created April 20, 2020 03:09
Webpack for Jekyll
{
"name": "name",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.5",
"babel-core": "^6.26.3",
"babel-loader": "^8.1.0",
@scottserok
scottserok / webpack.config.js
Created April 20, 2020 03:07
Webpack for Jekyll
var path = require("path");
module.exports = {
entry: "./src/index.js",
output: {
path: path.join(__dirname,"./assets/js/"),
filename: "bundle.js"
},
module: {
rules: [
@scottserok
scottserok / cookie_validation.rb
Created July 9, 2019 19:32
Extend CookieJar::CookieValidation with monkey-patched .domains_match method for Restforce workaround.
@scottserok
scottserok / tiny_graphql_server.rb
Last active May 8, 2019 17:52
Tiny GraphQL server to share authentication and authorization pattern for mutations
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'graphql'
gem 'rack'
gem 'webrick'
gem 'mail'
end
require 'json'
@scottserok
scottserok / ruby-pre-commit
Last active March 20, 2020 13:55
A Git pre-commit hook for Ruby projects that validates syntax, looks for any lingering puts or byebug statements.
#!/bin/sh
#
# A pre-commit hook for Ruby projects.
#
# == Installation
#
# From within a Ruby project directory in your terminal:
#
# curl https://gist.github.com/scottserok/0838cdda3f07a6eb30b44ee475b1e57c/raw/fe00beb4a69c529c6391def23a4dc61e2711c2cb/ruby-pre-commit >> .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit