Skip to content

Instantly share code, notes, and snippets.

Avatar
😉
I may be slow to respond.

Simone Lusenti lusentis

😉
I may be slow to respond.
View GitHub Profile
@lusentis
lusentis / script.js
Created Jan 7, 2021
AWS Account ID in browser's tab title
View script.js
// ==UserScript==
// @name Account ID in Tab Title
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://*.console.aws.amazon.com/*
// @grant none
// ==/UserScript==
@lusentis
lusentis / .sri-alias
Created Feb 13, 2018
bash alias definition for easy computation of SRI hashes :)
View .sri-alias
# usage:
# $ curl https://cdn.ravenjs.com/3.22.3/raven.min.js | sri
alias sri='openssl dgst -sha384 -binary | openssl base64 -A | cat <(echo -n "sha384-") - | xsel -bi && echo "SRI hash copied to clipboard :)"'
@lusentis
lusentis / parseS3URL.js
Last active Jan 31, 2017
parses an Amazon S3 URL and returns bucket, region and key
View parseS3URL.js
function parseS3URL(url) {
const tokens = /^https:\/\/([\w\d-]+)\.s3(-(\w\w-\w+-\d))?\.amazonaws\.com\/(.*?)((#|%23).*)?$/.exec(
url
);
if (!tokens) {
return false;
}
const [, bucket, , region = 'us-east-1', key] = tokens;
return { bucket, region, key };
}
View dawson-keepalive.js
// Usage:
// $ babel-node keepalive.js > keepalive-code.js && \
// zip keepalive-code.zip keepalive-code.js && \
// aws lambda update-function-code \
// --function-name DawsonKeepAliveProd \
// --zip-file fileb://./keepalive-code.zip && \
// rm keepalive-code*
import execa from 'execa';
import assert from 'assert';
@lusentis
lusentis / replicator.js
Created Dec 13, 2016
lambda (draft) to replicate a dynamodb table to S3
View replicator.js
export function replicator (replicatorInternalId, sourceLogicalName, destinationPhysicalName, destinationArn) {
if (replicatorInternalId === false) {
return {};
}
const resourcesSuffix = sourceLogicalName[0].toUpperCase() + sourceLogicalName.slice(1) + '' + replicatorInternalId;
const lambdaInlineCode = `
'use strict';
console.log('Loading function');
@lusentis
lusentis / replicator.js
Last active Sep 29, 2016
CloudFormation snippet to create a Lambda function which replicates a DynamoDB table
View replicator.js
function replicator(replicatorInternalId, sourceLogicalName, destinationPhysicalName, destinationArn) {
const lambdaInlineCode = `
'use strict';
console.log('Loading function');
const AWS = require('aws-sdk');
const dynamo = new AWS.DynamoDB({});
exports.handler = (event, context, callback) => {
@lusentis
lusentis / MultipleSelect.js
Last active Oct 3, 2017
multiple select with filters, like Django's
View MultipleSelect.js
import React, { PropTypes as Type } from 'react';
import R from 'ramda';
const textFilter = str =>
R.filter(
R.compose(
R.test(new RegExp(str, 'i')),
R.prop('text'),
)
@lusentis
lusentis / README.md
Last active Mar 14, 2016
add lifecycle methods to functional components
View README.md
import addLifecycle from './addLifecycle';

const wrapLifecycle = addLifecycle({
  handleComponentDidMount: triggerRequestFetch,
  handleComponentWillReceiveProps: Function,
});

// ...
@lusentis
lusentis / Packages
Last active Feb 1, 2016
My Sublime Config
View Packages
Packages.zip
(unzip in .config/sublime-text-3/)
https://mega.co.nz/#!bU4wSTKS!kNw-I6ngCvsZwsD51MTxqavySG2z2aLgBS-B6BzlEZo
View README
apm install sync-settings