Skip to content

Instantly share code, notes, and snippets.

View razor-x's full-sized avatar

Evan Sosenko razor-x

View GitHub Profile
@razor-x
razor-x / functions.yaml
Last active May 3, 2024 12:39
Sentry.io CloudFront Lambda@Edge tunnel
# TODO: Setup https://github.com/silvermine/serverless-plugin-cloudfront-lambda-edge
sentryOriginReq:
handler: handlers/handler.default
lambdaAtEdge:
distribution: AppDistribution
eventType: origin-request
includeBody: true
pathPattern: /_tunnel # TODO: Choose tunnel path.
import type { Middleware, createWithEdgeSpec } from 'edgespec'
const users: Record<string, { userId }> = {
fake_api_key1: { userId: 'fake-user-id-1' },
}
const withApiKey: Middleware = (req, ctx, next) => {
const apiKey = req.headers.get('authorization').split('Bearer ')
req.user = users[apiKey]
return next()
@razor-x
razor-x / server.py
Last active November 13, 2023 15:06
Python http.server that sets Access-Control-Allow-Origin header.
# Python http.server that sets Access-Control-Allow-Origin header.
# https://gist.github.com/razor-x/9542707
import os
import sys
import http.server
import socketserver
PORT = 8000
@razor-x
razor-x / apollo-client.ts
Last active December 22, 2022 10:41
AppSync using Apollo Client with subscription support, and custom domain via Lambda@Edge
import type {
NormalizedCacheObject,
PossibleTypesMap,
Resolvers,
TypePolicies
} from '@apollo/client'
import {
ApolloClient as Client,
InMemoryCache,
createHttpLink,
sudo mkdir /efi
# move efi mount
sudo rm -rf /boot/efi
# remove linux bootloader and kernals on /efi
# backup /boot
# reformat /boot to vfat
# copy /boot data back
# update UUID in fstab
sudo systemctl disable efistub-ucode-update@linux.path
sudo systemctl disable efistub-ucode-update@linux.service
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
@razor-x
razor-x / delete-versions.js
Created June 2, 2021 04:12
Delete GitHub package versions
import { createHttpClient } from '@meltwater/mlabs-http'
export default ({ githubOrg, githubToken, log }) =>
async (packageName, packageType = 'container') => {
if (!packageName) throw new Error('Missing packageName')
const client = createPackagesClient({
packageName,
packageType,
org: githubOrg,
@razor-x
razor-x / Rakefile
Last active March 12, 2021 13:22
Automatic publishing to GitHub Pages with Travis CI
desc 'Generate deck from Travis CI and publish to GitHub Pages.'
task :travis do
# if this is a pull request, do a simple build of the site and stop
if ENV['TRAVIS_PULL_REQUEST'].to_s.to_i > 0
puts 'Pull request detected. Executing build only.'
sh 'bundle exec rake build'
next
end
repo = %x(git config remote.origin.url).gsub(/^git:/, 'https:').strip
@razor-x
razor-x / README.md
Last active February 19, 2020 10:26
Load GitHub Gists asynchronously and optionally specify which file to show.

Load GitHub Gists asynchronously

This is now a Bower package: [gist-async]. [gist-async]: https://github.com/razor-x/gist-async

Requires jQuery.

Jekyll plugin included that modifies the gist markup added by its gist Liquid tag.

Load GitHub Gists asynchronously and optionally specify which file to show.

@razor-x
razor-x / shortcode-gist.php
Last active July 8, 2019 17:19
WordPress shortcode for loading gists asynchronously with gist-async.
// Created by timrourke.
// https://github.com/timrourke
//
// This silly little shortcode simplifies using Evan Sosenko's excellent
// script for async loading of github gists.
// https://github.com/razor-x/gist-async
//
// Plop this in your functions file or functionality plugin.
// Usage: [gist id="12345567" file="example.js"]
function async_gist_func($atts) {