Skip to content

Instantly share code, notes, and snippets.

// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@sivel
sivel / better-ssh-authorized-keys-management.md
Last active May 3, 2024 14:20
Better SSH Authorized Keys Management

Better SSH Authorized Keys Management

A seemingly common problem that people encounter is how to handle all of your users authorized_keys file.

People struggle over management, ensuring that users only have specific keys in the authorized_keys file or even a method for expiring keys. A centralized key management system could help provide all of this functionality with a little scripting.

One piece of functionality overlooked in OpenSSH is the AuthorizedKeysCommand configuration keyword. This configuration allows you to specify a command that will run during login to retrieve a users public key file from a remote source and perform validation just as if the authorized_keys file was local.

Here is an example directory structure for a set of users with SSH public keys that can be shared out via a web server:

@kimamula
kimamula / Optional.ts
Last active December 3, 2020 20:12
Implementation of Optional (Maybe) in TypeScript
class Some<A> implements Optional<A> {
constructor(private a: A) {
}
getOrElse(a: A) {
return this.a;
}
map<B>(func: (a: A) => B) {
return Optional(func(this.a));
}
match<B>(cases: {
@Rich-Harris
Rich-Harris / service-workers.md
Last active July 1, 2024 06:33
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@sportebois
sportebois / aws_mfa_auth.sh
Last active November 5, 2018 13:42
AWS CLI: Easy MFA auth
#!/usr/bin/env bash
set -e
# Note: this will overwite your AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY if you use it
# (I usually prefer using ~/.aws/credentials profile and leave those unset)
# Use this script by sourcing the output directly, like:
# $(./aws_mfa_auth.sh)
# Or
# $(./aws_mfa_auth.sh arn:aws:iam::123456789012:mfa/bob)