Skip to content

Instantly share code, notes, and snippets.

View lusentis's full-sized avatar

Simone Lusenti lusentis

View GitHub Profile
@lusentis
lusentis / keybase.md
Created March 11, 2024 17:06
keybase.md

Keybase proof

I hereby claim:

  • I am lusentis on github.
  • I am lanzone31 (https://keybase.io/lanzone31) on keybase.
  • I have a public key ASBIIEKCc7o4vqph1MvOEpI-Y-hi22GsOaqb4WiOx7iUcQo

To claim this, I am signing this object:

@lusentis
lusentis / script.js
Created January 7, 2021 12:30
AWS Account ID in browser's tab title
// ==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 February 13, 2018 14:11
bash alias definition for easy computation of SRI hashes :)
# 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 January 31, 2017 11:08
parses an Amazon S3 URL and returns bucket, region and key
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 };
}
// 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 December 13, 2016 16:48
lambda (draft) to replicate a dynamodb table to S3
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 September 29, 2016 16:25
CloudFormation snippet to create a Lambda function which replicates a DynamoDB table
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 October 3, 2017 05:11
multiple select with filters, like Django's
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 March 14, 2016 10:49
add lifecycle methods to functional components
import addLifecycle from './addLifecycle';

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

// ...
@lusentis
lusentis / Packages
Last active February 1, 2016 18:43
My Sublime Config
Packages.zip
(unzip in .config/sublime-text-3/)
https://mega.co.nz/#!bU4wSTKS!kNw-I6ngCvsZwsD51MTxqavySG2z2aLgBS-B6BzlEZo