Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Building stuff for @smallwins!

Ryan Block ryanblock

:shipit:
Building stuff for @smallwins!
View GitHub Profile
@ryanblock
ryanblock / destroy-cloudwatch-logs.js
Last active Feb 27, 2021
Destroy CloudWatch logs
View destroy-cloudwatch-logs.js
// I like using dotenv locally but that's up to you
// require('dotenv').config()
const aws = require('aws-sdk')
// eslint-disable-next-line
let logs = [
// Insert your logs here, eg '/aws/lambda/begin-production-foo',
]
const cloudwatchlogs = new aws.CloudWatchLogs()
@ryanblock
ryanblock / api-gateway-upgrade.js
Last active Apr 22, 2019
Arc API Gateway upgrade script
View api-gateway-upgrade.js
// I like using dotenv locally but that's up to you
require('dotenv').config()
const aws = require('aws-sdk')
const path = require('path')
const fs = require('fs')
const series = require('run-series')
const waterfall = require('run-waterfall')
const requestTemplate = fs.readFileSync(path.join(__dirname, 'node_modules', '@architect', 'architect', 'src', 'create', 'aws', 'create-http-route', 'create-route', '_request.vtl')).toString()
const requestFormPostTemplate = fs.readFileSync(path.join(__dirname, 'node_modules', '@architect', 'architect', 'src', 'create', 'aws', 'create-http-route', 'create-route', '_request-form-post.vtl')).toString()
const requestBinary = fs.readFileSync(path.join(__dirname, 'node_modules', '@architect', 'architect', 'src', 'create', 'aws', 'create-http-route', 'create-route', '_request-binary.vtl')).toString()
@ryanblock
ryanblock / example-begin-function.js
Created Dec 2, 2018
Example Begin cloud function
View example-begin-function.js
// This function is everything you need to build a Lambda-based app with Begin
exports.handler = async function http(req) {
return {
type: 'text/html; charset=utf8',
body: `<h1 class="center-text">Hello world!</h1>`
}
}
View get-index-test-b.js
test('can list cats', async t=> {
t.plan(1)
let result = await data.cats.scan({})
t.ok(result, 'got result')
console.log(result)
})
View get-index-test-a.js
test('can get /', async t=> {
t.plan(1)
let url = 'http://localhost:3333'
let result = await tiny.get({url})
t.ok(result.body, 'got a 200 response')
console.log(result.body)
})
View get-index-test.js
let arc = require('@architect/architect')
let data = require('@architect/data')
let tiny = require('tiny-json-http')
let test = require('tape')
let end // save a ref
test('start sandbox', async t=> {
t.plan(1)
end = await arc.sandbox.start()
t.ok('started sandbox')
})
@ryanblock
ryanblock / arc-esm-00.js
Created Nov 13, 2018
Architect + ES Modules - example Lambda
View arc-esm-00.js
const fs = require('fs')
const join = require('path').join
exports.handler = async function http(req) {
let module = req.params.module
let filePath = join(__dirname, 'node_modules', '@architect', 'views', module)
let exists = fs.existsSync(filePath)
if (exists) {
let file = fs.readFileSync(filePath).toString()
return {
type: 'text/javascript; charset=utf8',
View gist:b84edf9679b0e5ecc523596adaa19e76
// src/http/get-index/index.js
exports.handler = async function http(request) {
return {
type: 'text/html',
body: 'Hello world!' // 200 status by default
}
}
View keybase.md

Keybase proof

I hereby claim:

  • I am ryanblock on github.
  • I am ryanblock (https://keybase.io/ryanblock) on keybase.
  • I have a public key whose fingerprint is 14F0 9ABC 90E5 7F55 0690 0056 6C27 888B 0369 8554

To claim this, I am signing this object:

@ryanblock
ryanblock / @ryan tweetbot regex.md
Created Aug 29, 2012
How Tweetbot and regex made my Twitter replies usable again (filed under: #wrongryan)
View @ryan tweetbot regex.md

How Tweetbot and regex made my Twitter replies usable again

As it turns out, most normal humans are incapable of learning to use Twitter @ replies. And in case you don't follow me on Twitter: yes, my handle (@ryan) gets a lot of erroneous mentions. (The most amusing, random ones I've even taken to retweeting under the #wrongryan hashtag.)

Then Tweetbot -- and its ability to use regex as Twitter filters -- came along. Here's how the Tapbots guys and some regular expressions single-handedly made my Twitter replies usable again.

Notes and caveats

  • I'm not a regex expert. Far from it. I suck at regex, actually. If you have suggestions for improvements, please leave them below!
  • Some regex may look a little sloppy, but in actuality was written because TweetBot for Mac's regex filter support is very early, and things like repeats (expression{3,}) are buggy. So everything below should work without crashing Tweetbot for iPhone, iPad, and Mac.
  • Obvious, but not everyone should make use of every filter b