Skip to content

Instantly share code, notes, and snippets.

View prenagha's full-sized avatar

Padraic Renaghan prenagha

View GitHub Profile

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
@christiangenco
christiangenco / add_to_reading_list
Created February 17, 2016 21:28
command line utility to add urls to the Safari iOS and Mac reading list
#!/usr/bin/env osascript
-- usage:
-- add_to_reading_list "http://google.com" "http://yahoo.com"
on run argv
repeat with arg in argv
tell app "Safari" to add reading list item (arg as text)
end repeat
end run
/*
* Copyright (c) 2010 Apple Inc. All rights reserved.
*/
function characterNeedsScoreMultiplier(e) {
if (!e || e.length === 0)
return !1;
var t = e.charCodeAt(0);
return t > 11904 && t < 12031?!0 : t > 12352 && t < 12543?!0 : t > 12736 && t < 19903?!0 : t > 19968 && t < 40959?!0 : t > 44032 && t < 55215?!0 : t > 63744 && t < 64255?!0 : t > 65072 && t < 65103?!0 : t > 131072 && t < 173791?!0 : t > 194560 && t < 195103?!0 : !1
}
function domDistance(e, t, n) {
@lgarron
lgarron / copyToClipboard.html
Last active December 20, 2023 12:53
Simple `navigator.clipboard.writeText()` polyfill.
<script>
// A minimal polyfill for copying text to clipboard that works most of the time in most capable browsers.
// Note that:
// - You may not need this. `navigator.clipboard.writeText()` works directly in all modern browsers as of 2020.
// - In Edge, this may call `resolve()` even if copying failed.
// - In Safari, this may fail if there is nothing selected on the page.
// See https://github.com/lgarron/clipboard-polyfill for a more robust solution.
//
// License for this Gist: public domain / Unlicense
function writeText(str) {
@mcandre
mcandre / sort-by-size.md
Last active June 21, 2024 04:22
Sort file and directories recursively by size

UNIX

Files: ls -lSh | tac

Directories: du -hd 1 | sort -h

Requires GNU coreutils (e.g., macOS users can run brew install coreutils).

macOS

@gruber
gruber / Paste URL From Safari Tab.scpt
Created June 29, 2015 00:01
Paste URL From Safari Tabs
set _old_delims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {""}
tell application "System Events"
set _current_app to name of the first process whose frontmost is true
end tell
tell application "Safari"
set _urls to {}
repeat with i from 1 to 6 -- how many Safari windows to show URLs from
@weavenet
weavenet / delete_all_object_versions.sh
Created May 4, 2015 05:21
Delete all versions of all files in s3 versioned bucket using AWS CLI and jq.
#!/bin/bash
bucket=$1
set -e
echo "Removing all versions from $bucket"
versions=`aws s3api list-object-versions --bucket $bucket |jq '.Versions'`
markers=`aws s3api list-object-versions --bucket $bucket |jq '.DeleteMarkers'`
@ttscoff
ttscoff / gmail.plist
Last active February 20, 2025 09:33
Two of my favorite MailMate Keybindings
# Two of my favorite MailMate keybindings
# <http://manual.mailmate-app.com/custom_key_bindings>
#
# g,g jumps to first message in message list
# G jumps to last message in list
{
"g" = {
"g" = ( "makeFirstResponder:", "mainOutline", "selectFirstMessageRow:");
};
"G" = ( "makeFirstResponder:", "mainOutline", "selectLastMessageRow:");
@JadenGeller
JadenGeller / Semaphore.swift
Last active May 16, 2017 15:51
Swift Semaphore
struct Semaphore {
let semaphore: dispatch_semaphore_t
init(value: Int = 0) {
semaphore = dispatch_semaphore_create(value)
}
// Blocks the thread until the semaphore is free and returns true
// or until the timeout passes and returns false
// References:
// http://manual.mailmate-app.com/custom_key_bindings
// http://manual.mailmate-app.com/key_binding_selectors
// Custom
"E" = "expandAll:"; // expands all threads in current view
"T" = "showThread:"; // lower-case t doesn't work because it's bound to tags (?)
"l" = "copyAsLink:"; // copies message:// link for selected message
"y" = ( "selectWithFilter:", "#thread-id = ${#thread-id}", "archive:"); // http://protips.maxmasnick.com/mailmate-keyboard-shortcut-to-archive-all-messages-in-a-thread
"@[" = "backInHistory:"; // moves back in history, e.g. back to mailbox after performing a search. ESC also works for this.