Skip to content

Instantly share code, notes, and snippets.

View gmac's full-sized avatar

Greg MacWilliam gmac

View GitHub Profile
import Evaporate from 'evaporate';
import sparkMD5 from 'spark-md5';
import sha256 from 'js-sha256';
const uploader = Evaporate.create({
signerUrl: '/uploads/auth',
aws_key: 'AWS_PUBLIC_KEY',
bucket: 'your-bucket-name',
cloudfront: true,
computeContentMd5: true,
class UploadsController < ApplicationController
before_action :require_login
def auth
date_stamp = Date.strptime(params[:datetime], "%Y%m%dT%H%M%SZ").strftime("%Y%m%d")
secret_key = "AWS_SECRET_KEY"
aws_region = "us-east-1" # << set to your region
date_key = OpenSSL::HMAC.digest("sha256", "AWS4" + secret_key, date_stamp)
region_key = OpenSSL::HMAC.digest("sha256", date_key, aws_region)
@gmac
gmac / aws-cors-config.xml
Created September 10, 2018 03:32
Config for direct uploads to S3
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedMethod>GET</AllowedMethod>
<ExposeHeader>ETag</ExposeHeader>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
[{
"url": "https://78.media.tumblr.com/59102da2539294599648a6f2aa91b26b/tumblr_ocsdjcsiud1vn68joo1_1280.jpg",
"illustration_id": "bcd7f575-5c50-4c3b-bec7-9e90efdb56e8",
"artist_id": "fc021f3d-773a-4706-bbe7-f602324f511f"
}, {
"url": "https://78.media.tumblr.com/61078eeec886a777a864eb2240f2f5b1/tumblr_obp9kv0miM1vn68joo1_1280.jpg",
"illustration_id": "3b6677ad-7ddb-4668-857a-6c0ff052040b",
"artist_id": "fc021f3d-773a-4706-bbe7-f602324f511f"
}, {
"url": "https://78.media.tumblr.com/626fecef05b19c4680f74cb62b3204ff/tumblr_nuvsvjqqN01qepqmao1_1280.jpg",
This file has been truncated, but you can view the full file.
--
-- Name: illustrations; Type: TABLE; Schema: public; Owner: gregmacwilliam
--
CREATE TABLE illustrations (
id uuid DEFAULT gen_random_uuid() NOT NULL,
artist_id uuid NOT NULL,
artist_2_id uuid,
primary_oracle_id uuid NOT NULL,
This file has been truncated, but you can view the full file.
ALTER TABLE printings ADD COLUMN illustration_id uuid;
ALTER TABLE printings ADD COLUMN illustration_2_id uuid;
UPDATE printings AS p
SET illustration_id = uuid(j.illustration_id)
FROM (VALUES
('d0a7cb23-d229-43c5-addd-dcf423984b0c','38f37870-7b63-4596-bd7b-e4fdfb4d52b5',1),
('21004958-2c7e-4a55-bc80-411c4d780106','f868fd9b-79d8-4269-b13d-3b41bc586895',1),
('efba235e-04e5-449c-906c-0ac33f6d7929','044ee33d-deaa-4cdb-9e5f-f71d5cef572f',1),
{
"domain": "vox.com",
"cells": [
{
"slug": "UnisonNavListCell",
"bucket": "vox.com",
"data": {
"presto_component_data": "{\"trending_pinned\":false,\"communities_pinned\":false,\"nav_items\":[{\"title\":\"Politics\",\"url\":\"/policy-and-politics\",\"pinned\":false,\"all_link\":{\"title\":\"\",\"url\":\"\"},\"sub_items\":[],\"group_id\":30770},{\"title\":\"Explainers\",\"url\":\"/explainers\",\"pinned\":true,\"sub_items\":[],\"group_id\":24365},{\"title\":\"World\",\"url\":\"/world\",\"pinned\":false,\"all_link\":{\"title\":\"\",\"url\":\"\"},\"sub_items\":[],\"group_id\":30778},{\"title\":\"Culture\",\"url\":\"/culture\",\"pinned\":false,\"all_link\":{\"title\":\"\",\"url\":\"\"},\"sub_items\":[],\"group_id\":27608},{\"title\":\"Science & Health\",\"url\":\"/science-and-health\",\"pinned\":false,\"all_link\":{\"title\":\"\",\"url\":\"\"},\"sub_items\":[],\"group_id\":30772},{\"title\":\"Identities\",\"url\":\"/identities\",\"pinned\":false,\"all_link\":{\"title\":\"\",\"url\":\"\"},\"sub_items\":[],\"group_
@gmac
gmac / theme_editor.js
Created March 16, 2017 19:48
Notes for theme editor talk
// THEME
// Get plain variable text:
theme.getVar('color_breaker_fg')
// Get rendered variable value:
theme.getVarValue('color_breaker_fg')
// Compile mapped field dependencies:
theme.getDependencyGraph()
import Initializer from 'presto/initializer';
var $loaded = $.Deferred();
Initializer.registerComponent('site/font_loader', function(element, data) {
const STORAGE_NS = 'chorus-fonts-'+ data.version;
const FONTS_LOADED = ' fonts-loaded';
const SUCCESS = function() {};
var FontFaceObserver = require('./scripts/vendor/fontfaceobserver');
{
"android_icon": "https://cdn0.vox-cdn.com/dev/uploads/chorus_asset/file/7045788/sandbox-www-data-ip-10-61-185-107_/sandbox_VergeFlavicon192.0.png",
"cache_version": "201",
"color_accent": "#e5127d",
"color_body": "#424242",
"color_body_bg": "#ffffff",
"color_body_link_underline": "currentColor",
"color_border_nav": "transparent",
"color_border_thick": "#EFEFF0",
"color_breaker_bg": "#EFEFF0",