Skip to content

Instantly share code, notes, and snippets.

Padraic Renaghan prenagha

Block or report user

Report or block prenagha

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@prenagha
prenagha / RedirectCanonical.js
Created Sep 2, 2019
Lambda@Edge to redirect from non-canonical (example.net) to canonical (example.com)
View RedirectCanonical.js
'use strict';
/**
* Deploy this Lambda@Edge, in Origin Request event,
* to a CloudFront distribution that hosts the
* NON-Canonical domains. It will redirect everything
* to the canonical version of the URL.
* And let CloudFront and browsers cache the redirect.
*/
exports.handler = (event, context, callback) => {
@prenagha
prenagha / DefaultIndexHTML.js
Created Sep 2, 2019
Lambda@Edge to redirect to default HTML page
View DefaultIndexHTML.js
'use strict';
const path = require('path');
/**
* Redirects URI to default document.
* Any URI without an extension is assumed to be
* a directory reference and will have '/index.html'
* appended to the URI.
* Useful as Lambda@Edge on CloudFront Origin Request event
@prenagha
prenagha / LogRetainManager.py
Last active Oct 31, 2018
Lambda CloudWatch Log Retention Manager
View LogRetainManager.py
import boto3
import os
def lambda_handler(event, context):
default_region = os.environ.get('AWS_REGION', 'us-east-1')
retain_days = int(os.environ.get('RETAIN_DAYS', '30'))
session = boto3.Session()
client = session.client('ec2', region_name=default_region)
@prenagha
prenagha / log-retain-manager-policy.json
Last active Oct 17, 2018
Set the retention days on any AWS CloudWatch log group that isn't set yet
View log-retain-manager-policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "SetLogRetain",
"Effect": "Allow",
"Action": [
"logs:DescribeLogGroups",
"ec2:DescribeRegions",
"logs:PutRetentionPolicy"
@prenagha
prenagha / DebugEvent.js
Created Oct 16, 2018
Lambda@Edge CloudFront Debugging Sample Records
View DebugEvent.js
'use strict';
/**
* Lambda@Edge to log CloudFront event and context.
* Note: this runs in Lambda@Edge which means it runs in a variety
* of regions, the region closest to the browser making the request.
* So be sure and check other regions if you don't see the logs in
* CloudWatch in the region you normally use.
*
* https://medium.com/@jbesw/postcards-from-lambda-the-edge-11a43f215dc1
@prenagha
prenagha / sVim.rc
Last active Oct 2, 2018
sVim Safari Extension settings
View sVim.rc
" sVim Safari Extension settings
" https://github.com/flipxfx/sVim
let scrollstep = 120
" Neat shortcuts
map "v" goToInput
map "c" lastClosedTab
map "e" quit
map "d" createHint
@prenagha
prenagha / karabiner.json
Created Jun 14, 2017
Karabiner Elements Config for Basic vi-style movements and Hyper Key
View karabiner.json
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"rules": [
@prenagha
prenagha / micropub-micro-blog-example.sh
Created Apr 27, 2017
Micropub sample post to Micro.blog
View micropub-micro-blog-example.sh
#!/bin/bash
# http://help.micro.blog/2017/api-posting/
# https://indieweb.org/Micropub
URL="https://micro.blog/micropub"
TOKEN="aabbcc"
CONTENT="Sample Post Here - http://example.com"
curl --verbose \
View keybase.md

Keybase proof

I hereby claim:

  • I am prenagha on github.
  • I am prenagha (https://keybase.io/prenagha) on keybase.
  • I have a public key ASC04lRyBGeCmnZDKGqGfErdoTXJCGmx9XgSGdj5Nive8go

To claim this, I am signing this object:

@prenagha
prenagha / init.lua
Created Sep 30, 2016
Hammerspoon Config File, Hyper Key, Karabiner-Elements
View init.lua
-- hattip https://github.com/lodestone/hyper-hacks
-- hattip https://gist.github.com/ttscoff/cce98a711b5476166792d5e6f1ac5907
-- A global variable for the sub-key Hyper Mode
k = hs.hotkey.modal.new({}, 'F18')
-- Hyper+key for all the below are setup somewhere
-- The handler already exists, usually in Keyboard Maestro
-- we just have to get the right keystroke sent
You can’t perform that action at this time.