Skip to content

Instantly share code, notes, and snippets.

View ryanblock's full-sized avatar
:shipit:
Building stuff for @beginner-corp!

Ryan Block ryanblock

:shipit:
Building stuff for @beginner-corp!
View GitHub Profile
@ryanblock
ryanblock / @ryan tweetbot regex.md
Created August 29, 2012 02:27
How Tweetbot and regex made my Twitter replies usable again (filed under: #wrongryan)

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

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 / gist:b84edf9679b0e5ecc523596adaa19e76
Created October 22, 2018 03:04
Architect 4.0 HTTP code sample
// src/http/get-index/index.js
exports.handler = async function http(request) {
return {
type: 'text/html',
body: 'Hello world!' // 200 status by default
}
}
@ryanblock
ryanblock / arc-esm-00.js
Created November 13, 2018 05:49
Architect + ES Modules - example Lambda
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',
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')
})
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)
})
test('can list cats', async t=> {
t.plan(1)
let result = await data.cats.scan({})
t.ok(result, 'got result')
console.log(result)
})
@ryanblock
ryanblock / example-begin-function.js
Created December 2, 2018 22:28
Example Begin cloud function
// 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>`
}
}
@ryanblock
ryanblock / api-gateway-upgrade.js
Last active April 22, 2019 20:24
Arc API Gateway upgrade script
// 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 / destroy-cloudwatch-logs.js
Last active February 27, 2021 15:31
Destroy CloudWatch logs
// 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()