Skip to content

Instantly share code, notes, and snippets.

View EvanK's full-sized avatar

Evan Kaufman EvanK

  • Washington, USA
View GitHub Profile
@EvanK
EvanK / aws-schedule-expressions.pl
Last active March 11, 2024 20:58
A work in progress PCRE for matching [AWS EventBridge scheduling expressions](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-cron-expressions.html). See it in action [on RegExr](https://regexr.com/7t6id).
# the whole enchilada...
/
^
(
rate\(
(
(
1[ ]+(hour|minute|day))
|
([0-9]+[ ]+(hours|minutes|days)
@EvanK
EvanK / docs-generation.md
Last active February 29, 2020 20:05
Generating static docs for caps-api - like pushing a boulder uphill

Available tooling

Unfortunately, most useful tools for generating static documentation from a swagger spec are no longer maintained or only support swagger's 2.0 format -- we are using the 3.0 format.

The only tool I could find was swagger-codegen, which is built in and requires dependencies in (gag) Java.

Static html

Codegen allows us to generate a single-page static document:

# configuring our local server for auth via Google
OIDCRedirectURI /example/redirect_uri
OIDCCryptoPassphrase some-big-fancy-secret-passphrase
OIDCProviderMetadataURL https://accounts.google.com/.well-known/openid-configuration
# ensure the provider (Google in this case) gives us the user email
OIDCScope "openid email"
# credentials from the Google API console
OIDCClientID 123456789012-somelonghashedid.apps.googleusercontent.com
@EvanK
EvanK / gist:6d43cb9fa7b9d704d767
Created September 18, 2014 02:56
keybase.md
### Keybase proof
I hereby claim:
* I am evank on github.
* I am evanskaufman (https://keybase.io/evanskaufman) on keybase.
* I have a public key whose fingerprint is A841 C275 E509 6657 3814 0689 6508 E211 586F 8E5A
To claim this, I am signing this object:
@EvanK
EvanK / cap2.sh
Created May 27, 2014 19:56
Deploying specific branch/committish in Capistrano 2 vs 3
# -S key=value
cap staging deploy -S branch=42-super-awesome-feature-branch
@EvanK
EvanK / nope.xml
Created November 19, 2013 22:45
Pro tip: PHPUnit's test suite "exclude" nodes don't do wildcard expansion. Took me longer than I'd like to admit figuring this out.
<phpunit>
<testsuites>
<testsuite name="Unit">
<directory>../src/*/Bundle/*Bundle/Tests</directory>
<exclude>src/*/Bundle/*Bundle/Tests/Functional</exclude>
</testsuite>
</phpunit>
@EvanK
EvanK / .gitconfig
Created October 23, 2013 15:57
If you don't have a `.gitconfig` file in your home directory, create it: touch ~/.gitconfig
[user]
email = you@yourprovider.com
name = The name you want showing up in commits
[core]
editor = vi
[push]
default = current
@EvanK
EvanK / file-basename.pl
Created April 22, 2011 11:22
Perl `basename` and `dirname` module-free implementations
# WHY would we need this? For a situation where loading File::Basename isn't possible
# For example, in a BEGIN block, to tinker with @INC.
sub basename {
my $file = shift;
$file =~ s!^(?:.*/)?(.+?)(?:\.[^.]*)?$!$1!;
return $file;
}
sub dirname {
@EvanK
EvanK / gist:908834
Created April 7, 2011 21:56
Remove a deleted branch from a remote
# remove the branch "branch-name" from the remote "origin"
git push origin :branch-name
@EvanK
EvanK / working_dir.sh
Created February 2, 2011 21:21
dirname(realpath($SOMEPATH)) in bash
#!/bin/sh
# 1. takes $0 (the currently running script)
# 2. puts it through `readlink -f` to resolve any symlinks
# 3. puts it through `dirname` to remove the filename
working_dir=$(dirname $(readlink -f $0))
# so if i symlink a script from /home/ekaufman/myinit.sh to /etc/init.d/mything then even if I
# execute /etc/init.d/mything, ${working_dir} will be "/home/ekaufman"